C/C++

Написать программу на. C++

Создать массив целых чисел из диапазона [-13;10]. Вывести на экран
минимальный элемент второго столбца. В каждом столбце сменить знак максимального элемента на противоположный
#include <algorithm>
#include <iostream>
#include <random>
#include <iomanip>
using namespace std;
int main() {
const auto n = 5U, m = 16U;
int matrix[n][m];
const auto a = -13, b = 10;
uniform_int_distribution<> uid(a, b);
mt19937 gen{ random_device()() };
auto rand = [&] { return uid(gen); };
auto print = [](int x) { cout << setw(4) << x; };
for (auto& row : matrix) generate(begin(row), end(row), rand);
for (const auto& row : matrix) {
for_each(begin(row), end(row), print);
puts("");
}
puts("");
auto max = matrix[0][1];
for (auto i = 1U; i < n; ++i) {
if (matrix[i][1] > max) max = matrix[i][1];
}
cout << " max: " << max << "\n\n";
for (auto j = 0U; j < n; ++j) {
auto index = 0;
auto max = matrix[index][j];
for (auto i = 1U; i < n; ++i) {
if (matrix[i][j] > max) {
max = matrix[i][j];
index = i;
}
}
matrix[index][j] = ~matrix[index][j] + 1;
}
for (const auto& row : matrix) {
for_each(begin(row), end(row), print);
puts("");
}
system("pause > nul");
}
Максим Ершов
Максим Ершов
99 574
Лучший ответ
в плане "минимальный элемент второго столбца"? массив же одномерный получается
Станислав Терентьев В задании так написано
[-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10]м [-13;10] [-13;10] [-13;10] [-13;10]мм [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10]м [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10] [-13;10]