首页 > 技术文章 > c语言二维数组求最大值

chaoba 2016-11-20 22:07 原文

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int i,j,row=0,colum=0,max;
 5     int a[3][4]={{1,2,3,4},{9,8,7,6},{-10,10,-5,2}};
 6     max=a[0][0];
 7 for (i=0;i<=2;i++)
 8 {
 9     for (j=0;j<=3;j++)
10     {
11         if (a[i][j]>max)
12         {
13             max=a[i][j];
14             row=i;
15             colum=j;
16         }
17     }
18 }
19 printf("max=%d,row=%d,colum=%d",max,row,colum);
20 printf("\n");
21 
22 }

 

推荐阅读