1. 程式人生 > >找數列中的最大數及其位置

找數列中的最大數及其位置

#include <stdio.h>
#include <math.h>
int main()
{
    int i,j,row,cloumn,max;
    int a[3][4]={{1,2,3,4},{3,2,5,6},{1,10,9,8}};
    max=a[0][0];
    for(i=0;i<3;i++)
    {
        for(j=0;j<4;j++)
        {
             if(a[i][j]>max)
             {
                 max=a[i][j];
                row=i;
                cloumn=j;
             }
        }
    }
    printf("最大數為:%d\n第%d行,第%d列",max,row,cloumn);
    return 0;
}