為什我我最后打else運行不起 加上if才可以
#include <stdio.h>
int main()?
{
? ? int score = 7200;
? ? if(score>=10000)
? ? {
? ? ? ? printf("鉆石玩家");
? ? }
? ? else if(score>=5000||score<10000)
? ? {
? ? ? ? printf("白金玩家");? ??
? ? }
? ? else if(score>=1000||score<5000)
? ? {
? ? ? ? printf("青銅玩家");? ? ?
? ? }
? ? else (score<1000)
? ? {
? ? ? ? printf("普通玩家");? ??
? ? }
? ? return 0;
}
2018-06-26
else后面不能直接跟條件判斷,else?if才行,直接跟就是語法錯誤,肯定運行不了。把else后面的(score<1000)刪掉就行了,這并不是必要的,因為前面的情況你都判斷了,最后剩下的一定是小于1000的了
2018-09-11
123
2018-07-12
2018-07-01
#include <stdio.h>
int main()?
{
? ? int score = 7200;
? ? //完善一下代碼
? ? if(score>=10000)
? ? {
? ? ? ? printf("鉆石玩家");
? ? }
? ? else
? ? if(score>=5000)
? ? {
? ? ? ? printf("白金玩家"); ? ?
? ? }
? ? else
? ? if(score>=1000)
? ? {
? ? ? ? printf("青銅玩家"); ? ??
? ? }
? else
? ? {
? ? ? ? printf("普通玩家"); ? ?
? ? }
? ? return 0;
}
2018-07-01
else 不能加條件判斷,else 表示上面的if 和 else if 的條件都不滿足就執(zhí)行當(dāng)前的代碼