46、求矩阵的最大值

#include<iostream>
using namespace std;
int main(){

	int  a[3][4] = { { 1, 3, 4, 6 }, { 2, 4, 6, 8 }, { 1, 3, 4, 5 } };
	int  max = a[0][0];
	int  row = 0;
	int  colnum = 0;
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 4; j++){
			if (a[i][j] >max){
				max = a[i][j];
				row = i;
				colnum = j;
			}
		}
	}
	cout << "a[" << row << "][" << colnum << "]=" << max << endl;
	system("pause");
}

 

点赞