#include"stdio.h"voidmain(){int arr[3][3];int i,j,max,min;int max_i,max_j;int min_i,min_j;printf("please input the arr:\n");for(i=0;i<3;i++)for(j=0;j<3;j++)scanf("%d",&arr[i][j]);for(i=0;i<3;i++){for(j=0;j<3;j++)printf("%5d",arr[i][j]);printf("\n");}
max=arr[0][0];
min=arr[0][0];for(i=0;i<3;i++)for(j=0;j<3;j++){if(arr[i][j]>max){
max=arr[i][j];
max_i=i;
max_j=j;}if(arr[i][j]<min){
min=arr[i][j];
min_i=i;
min_j=j;}}printf("the result is :\n");printf("the max element is %d, index is [%d][%d]\n\n",max,max_i,max_j);printf("the min element is %d, index is [%d][%d]\n\n",min,min_i,min_j);}
第四十六题:定义一个3行3列的二维数组,从键盘输入9个数的值。输出其中最大值和最小值及其所在的行列坐标#include "stdio.h" void main() { int arr[3][3]; int i,j,max,min; int max_i,max_j; int min_i,min_j; printf("please input the arr:\n"); for(i=0;i<3;i++) for(j=0;j