第一种,利用而二维数组
#include <stdio.h>
int main(){
int m,n,i,j,row,colum;
scanf("%d %d",&m,&n);
int a[m][n];
for ( i=0;i<m;i++){
for( j=0;j<n;j++){
scanf("%d",&a[i][j]);
}
}int max=a[0][0];
for( i=0;i<m;i++){
for( j=0;j<n;j++){
if(a[i][j]>max) {
max=a[i][j];
row=i+1;
colum=j+1;
}
}
}printf("该%d*%d矩阵的最大元素信息如下:\n",m,n);
printf("max=%d\n",max);
printf("row=%d\n",row);
printf("colum=%d\n",colum);}
输出结果
2 3
1 6 3
4 2 5
该2*3矩阵的最大元素信息如下:
max=6
row=1
colum=2
第二种正在开发中