Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language input integer two-dimensional array a[4][3], calculate the value and position of the largest element in the two-dimensional array (row, column
C language input integer two-dimensional array a[4][3], calculate the value and position of the largest element in the two-dimensional array (row, column
# include & ltstdio.h & gt

void main(){

int a[3][4],max,maxi=0,maxj=0,I,j;

Printf ("Please enter: \ n");

for(I = 0; I<3; i++)

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

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

max = a[0][0];

for(I = 0; I<3; i++)

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

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

max = a[I][j];

maxi = I; maxj = j;

}

Printf ("The value of the largest element in this two-dimensional array is %d, in row %d and column %d \ n", max, maxi+ 1, maxj+1);

It's just a modification of the one upstairs. The previous code is flawed. If all the inputs are negative, then your output is wrong.