Rytis Rytis - 15 days ago 5
C Question

2D array how to print a number and it's coordinates

I need to find and print out the max and min number in each row of a 2D array. This is what I have tried so far.

int max(int N, int masyvas[][])
{
int i, j, max[N][N]
for(i=0; i<N; i++)
for(j=i; j<N; j++)
if(masyvas[i][j] > max) max=masyvas[i][j];
return max;
}


I know this doesn't work, but is it any close to being at least useful? Any suggestions on how should I approach this?

Answer
int i, j, max, min;
for(i=0; i<N; i++) {
  max = 0;
  min = 0;
  for(j=i; j<N; j++    ) {
    if (masyvas[i][j] > max) 
       max = masyvas[i][j];
    if (masyvas[i][j] < min) 
       min = masyvas[i][j];
   }
}