#include
using namespace std;
int main() {
const int n=5;
int p[n][n];
srand(time(NULL));
cout << "Матрица:\n";<br> for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
p[i][j]=rand() % 50;
cout << p[i][j] << " ";<br> }
cout << "\n";<br> }
int max = p[2][0], jmax=0;
for(int j = 1; j if (p[2][j]>max) {
max = p[2][j]; jmax = j;
}
cout << "max = p[3,"<<jmax+1<<"] = "<<p[2][jmax]<<"\n";<br>}
Пример:
Матрица:
33 28 18 49 22
9 43 6 18 37
2 25 8 36 21
29 6 1 35 5
46 23 42 27 46
max = p[3,4] = 36