Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - There is a plastic two-dimensional array with the size of m n, and it is required to find out the row and column where the maximum value is located and the maximum value.
There is a plastic two-dimensional array with the size of m n, and it is required to find out the row and column where the maximum value is located and the maximum value.
# include & ltstdio.h & gt

int fi,fj,max

int a[500][500];

void find(int a[500][500],int m,int n)

{

int i,j;

for(I = 0; I & ltm;; i++)

{

for(j = 0; j & ltn; j++)

{

if(max & lt; a[i][j])

{

max = a[I][j];

fi = I;

FJ = j;

}

}

}

}

int main()

{

int m,n,I,j;

Printf ("Enter the number of rows and columns of the array:");

scanf("%d%d ",& ampm & amp; n);

Printf ("input array element \ n");

for(I = 0; I & ltm;; i++)

{

for(j = 0; j & ltn; j++)

scanf("%d ",& ampa[I][j]);

}

max =-0x fffffff; //Assign to the smallest number first.

Find (a, m, n);

Printf ("The largest element is in row %d and column %d, which is% d \ n", fi+ 1, FJ+ 1, max);

Returns 0;

}