if(){}
else if(){}
else
第一 没有if是不能写 else if 和else的.
第二 用if或者else if,应该看你第二个判断条件是否要在第一个判断条件的基础上进行。
例如: int a = 1;
int b = 1;
if(a==1){printf("hello world\n");}
else if (b==1){printf("hello");}
else {printf("no");}
在本段函数中 因为符合第一条语句,所以输出helloworld elseif 和else不执行;
假如else if改为 if 则在打印hello world 的基础上还要打印 hello。
其实在本质上 else if(b==1)的意思是if(b==1&&a!=1)