這兩個(gè)有什么區(qū)別嗎?
#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,第一個(gè)是5000到10000是白金玩家,第二個(gè)是大于5000是白金玩家,可當(dāng)大于1w的時(shí)候第二個(gè)代碼會(huì)直接判定為鉆石玩家。
加上&&你可以從青銅玩家開始寫,可以避免當(dāng)score>10000的時(shí)候直接輸出青銅玩家