Объяснение:
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <iostream>
using namespace std;
int max_row(int **a, int m, int c) {
int mr = 0;
for (int r = 1; r < m; ++r) if (a[mr][c] < a[r][c]) mr = r;
return mr;
}
int main() {
srand(time(0));
cout << "m n? ";
int m, n; cin >> m >> n;
cout << "\n матрица: \n";
int **a = new int *[m];
for (int r = 0; r < m; ++r) {
a[r] = new int[n];
for (int c = 0; c < n; ++c) cout << setw(4) << (a[r][c] = rand() % 1000);
cout << endl;
int mc = 0, mr = max_row(a, m, 0);
cout << "\n максимумы в столбцах: \n" << setw(4) << a[mr][0];
for (int c = 1; c < n; ++c) {
int cmr = max_row(a, m, c);
cout << setw(4) << a[cmr][c];
if (a[mr][mc] > a[cmr][c]) {
mc = c;
mr = cmr;
cout << "\n\n искомый элемент: a[" << mr << "][" << mc << "] = " << a[mr][mc] << endl;
return 0;
Объяснение:
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <iostream>
using namespace std;
int max_row(int **a, int m, int c) {
int mr = 0;
for (int r = 1; r < m; ++r) if (a[mr][c] < a[r][c]) mr = r;
return mr;
}
int main() {
srand(time(0));
cout << "m n? ";
int m, n; cin >> m >> n;
cout << "\n матрица: \n";
int **a = new int *[m];
for (int r = 0; r < m; ++r) {
a[r] = new int[n];
for (int c = 0; c < n; ++c) cout << setw(4) << (a[r][c] = rand() % 1000);
cout << endl;
}
int mc = 0, mr = max_row(a, m, 0);
cout << "\n максимумы в столбцах: \n" << setw(4) << a[mr][0];
for (int c = 1; c < n; ++c) {
int cmr = max_row(a, m, c);
cout << setw(4) << a[cmr][c];
if (a[mr][mc] > a[cmr][c]) {
mc = c;
mr = cmr;
}
}
cout << "\n\n искомый элемент: a[" << mr << "][" << mc << "] = " << a[mr][mc] << endl;
return 0;
}