问题 4020 --最大值及所在位置(完善程序)

4020: 最大值及所在位置(完善程序)

时间限制: 1 Sec  内存限制: 128 MB
提交: 781  解决: 686
[提交][状态][命题人:]

题目描述

有一个3*4的矩阵,要求编写程序求出其中值最大的那个元素的值,以及其所在的行号和列号
#include<iostream>
using namespace std;
int main( )
{
	int a[3][4],row=____(1)____,column=____(2)____;
	for(int i=0;i<=2;i++)
		for(int j=0;j<=3;j++)
			cin>>a[i][j];
	int maxv=a[0][0];
	for(int i=0;i<=2;i++)
		for(int j=0;j<=3;j++)
			if(a[i][j]>maxv)
			{
				____(3)______;
				row=i;
				column=j;
			}
	cout<<"max="<<maxv<<",row="<<row<<",column="<<column;
    return 0;
}

输入

输出

样例输入
Copy
1 2 3 4
3 5 7 9
2 4 6 10
样例输出
Copy
max=10,row=2,column=3

提示

来源

[提交][状态]