I have 2D array, I need to write a function to find which row has the biggest sum, and if there is more than one row with the same sum, I need to print no particular max. This is what I wrote so far:
int find_max_sum(int b[N][N])
{
int row_sum = 0;
int row_max = -1;
int i,j,k;
int counter=0;
for(int i =0;i<N;i++)
{
row_sum = 0;
for (j = 0; j < N; ++j)
{
row_sum += b[i][j] ;
}
if(row_max < row_sum)
{
row_max = row_sum;
}
}
for (i = 0; i < N; i++)
{
for (j= 0;j< N;j++)
{
if(k=row_max);
counter++;
}
}
if (counter>1)
return(printf("No unique max.n"));
else
return row_max;
}
Now I need help with the counter thing, and if the function is int how can it return prints? Is it possible?
Aucun commentaire:
Enregistrer un commentaire