Создать массив целых чисел из диапазона [-13;10]. Вывести на экран
минимальный элемент второго столбца. В каждом столбце сменить знак максимального элемента на противоположный
C/C++
Написать программу на. C++
#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");
}
#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");
}
в плане "минимальный элемент второго столбца"? массив же одномерный получается
Станислав Терентьев
В задании так написано
[-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]
Похожие вопросы
- Помогите написать программу на C++
- Написать программу на c++
- Помоги пожалуйста написать программу на C++
- Написать программу на C++.Создать класс vector3d, задаваемый тройкой координат. Создать конструктор...
- Помогите написать программу на C++
- Написать программу на C/C++. Найти количество отрицательных элементов под побочной диагональю.
- Помогите написать программу на C++
- ПОМОГИТЕ НАПИСАТЬ ПРОГРАММУ НА C++ ИСПОЛЬЗУЯ ТОЛЬКО ЦИКЛЫ.
- Написать программу на c++ с готовым кодом и блок схемой
- Написать программу на C++