- if else语句嵌套,并且最后max只有一个单一出口,方便以后使用max值
#include<stdio.h>
int main()
{
int a,b,c;
printf("Please enter the value of a,b,c:");
scanf("%d %d %d",&a,&b,&c);
int max=0;
if(a>b){
if(a>c){
max=a;
}else{
max=c;
}
}else{
if(b>c){
max=b;
}else{
max=c;
}
}
printf("The max is %d\n",max);
return 0;
}
- 级联的if-else if
举个小栗子,分段函数的判断