I have this function, and I want your help to find if there is more than one maximum. If more than one maximum exists, I want to print "no unique max".
The code below successfully finds the maximum, but the counter, which countes how many times a maximum appears is not working and I get this message:
suggest braces around empty body in c
int find_max(int b[N][N])
{
int max = b[0][0];
int x,y;
int counter=0;
int a=0,v=0,c=0;
for (x = 0; x < N; x++)
{
for (y = 0; y < N; y++)
{
if (max < b[x][y])
{
max = b[x][y];
a=x;
v=y;
}
}
}
c=((a*10)+v);
for (x = 0; x < N; x++)
{
for (y = 0; y < N; y++)
{
if(max);
{
counter++;
}
}
}
if(counter>1)
printf("no uniqe max");
else
return c;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…