在多重if-else-if語句中,為何有的情況無法在最后的條件用else, 必須用else if
#include <stdio.h>
int main()
{
??? int score = 7200;
??? if(score >= 10000)//完善一下代碼
???
??? {
??????? printf("鉆石玩家");
??? }
??? else if(score>=5000)
??? {
??????? printf("白金玩家");???
??? }
??? else if(score>=1000)
??? {
??????? printf("青銅玩家");????
??? }
??? else(score>=0)/*這里用else它顯示錯誤的,但是改成else if就可以了,為什么不可以用else*/
??? {
??????? printf("普通玩家");???
??? }
??? return 0;
}
2019-09-04
因為else是判斷的,而這里是加了條件的,所以要用else if語句,if表示使用后面的條件