這兩個有什么區別嗎?
#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
? ? {
? ? ? ? printf("普通玩家");? ??
? ? }
? ? return 0;
}
#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;
}
2021-04-25
&&是且的意思,比如score>=5000&&score<10000,score>=5000,第一個是5000到10000是白金玩家,第二個是大于5000是白金玩家,可當大于1w的時候第二個代碼會直接判定為鉆石玩家。
加上&&你可以從青銅玩家開始寫,可以避免當score>10000的時候直接輸出青銅玩家