else if会判断在它上面的if或else if是否满足条件,如果满足条件,不管else if是否满足条件,都不会执行
例如
int max(int a, int b, int c)
{
int max = a;
if (max <= b)
max = b;
else if (max <= c)
max = c;
return max;
}
int max(int a, int b, int c)
{
int max = a;
if (max <= b)
max = b;
if (max <= c)
max = c;
return max;
}
二者只差了else结果却不相同。
标签:满足条件,return,int,max,else,ifelse,关于 From: https://blog.51cto.com/u_16220477/7475121