#include<stdio.h> void main() { int a[3][3]={{2,5,7},{1,8,6},{9,7,6}}; int i,j; int r[3]={a[0][0],a[1][0],a[2][0]}; for(i=0;i<3;i++) { for(j=1;j<3;j++) { if(r[i]<a[i][j]) r[i]=a[i][j]; } printf("第%d行最大是%d\n",i+1,r[i]); }
#include <stdio.h> int main (void) { int a[3][3]={ 2,5,7,1,8,6,9,7,6},i,j,max; for(i=0;i<3;i++) { max=a[i][0]; for(j=0;j<3;j++) { if(a[i][j]>max) { max=a[i][j]; } printf ("%i ",a[i][j]); } printf ("max=%i\n",max); } return 0; }