
C/C++
Помогите решить задание на C++
Здравствуйте всем читающим, столкнулся с такой проблемой что совсем не могу решить задачу 6,нету даже малейших представлений, если есть у кого подобный код пожалуста скиньте, или ссылку на форум где можно почитать об этом

#include
#include
#include
using namespace std;
struct Position {
size_t row;
size_t column;
Position() : row(0), column(0) {}
Position(const size_t r, const size_t c) : row(r), column(c) {}
};
size_t input(const char* msg, size_t a, size_t b) {
if (a > b) swap(a, b);
size_t value = 0;
while (value < a || value > b) {
cout > value;
cin.ignore(0x1000, '\n');
}
puts("");
return value;
}
double** create(const size_t n) {
uniform_int_distribution uid(1000, 9999);
mt19937 gen{ random_device()() };
auto m = new(nothrow) double*[n];
if (m != nullptr) {
for (size_t i = 0; i < n; ++i) {
m[i] = new(nothrow) double[n];
size_t j = 0;
if (m[i] != nullptr) {
while (j < n) {
m[i][j] = uid(gen) / 100.0;
++j;
}
} else {
for (size_t k = 0; k < j; ++k) delete[] m[k];
delete[] m;
m = nullptr;
break;
}
}
}
return m;
}
double** destroy(double** m, size_t n) {
if (m != nullptr) {
for (size_t i = 0; i < n; ++i) delete[] m[i];
delete[] m;
m = nullptr;
}
return m;
}
void show(double** m, const size_t n, const streamsize w, const size_t lim) {
if (!m || !n) {
puts("No data!");
return;
}
if (n > lim) {
puts("Sorry... Too much data!");
return;
}
cout
Turinobol
Спасибо большое!
#include
#include
#include
using namespace std;
const int MAX_N = 10000;
int n;
double M[MAX_N][MAX_N];
int main() {
// Seed the random number generator with the current time
srand(time(0));
// Read n
cin >> n;
// Fill the matrix with random numbers
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
M[i][j] = rand() / (double)RAND_MAX;
}
}
// Find the minimum element on the main diagonal
int min_col = 0;
double min_val = M[0][0];
for (int i = 1; i < n; i++) {
if (M[i][i] < min_val) {
min_col = i;
min_val = M[i][i];
}
}
// Find the maximum element on the side diagonal
int max_col = 0;
double max_val = M[0][n-1];
for (int i = 1; i < n; i++) {
if (M[i][n-1-i] > max_val) {
max_col = n-1-i;
max_val = M[i][n-1-i];
}
}
// Swap the columns in which the minimum and maximum elements are located
for (int i = 0; i < n; i++) {
swap(M[i][min_col], M[i][max_col]);
}
// Print the modified matrix
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout
Олег Панковец
double [10000][10000] жирно для стека
double *tmp = new double[n*n];
double (*M)[n] = reinterpret_cast<double(*)[n]>(tmp);
double *tmp = new double[n*n];
double (*M)[n] = reinterpret_cast<double(*)[n]>(tmp);
Turinobol
Спасибо, большое!
Похожие вопросы
- Помогите решить задание на c++
- Помогите решить задачу по C++!
- Помогите решить задачу на C++
- Помогите решить задачу на C++.
- Помогите решить задачу на c++
- Помогите с заданием на C++
- Помогите решить задание
- СРОЧНО! Помогите решить 2 задачи C++
- Помогите решить задачу на C++
- Помогите решить задачу на C++