为了账号安全,请及时绑定邮箱和手机立即绑定

求解释求解释 没有错误啊 ?????

#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;

}


正在回答

5 回答

#include <stdio.h>

int main() 

{

    int score = 7200;

    //完善一下代码

    if(score >= 10000)

    {

        printf("%s\n","钻石玩家");

    }

    else if(score >= 5000)

    {

        printf("%s\n","白金玩家");    

    }

    else if(score >= 1000)

    {

        printf("青铜玩家");     

    }

    else

    {

        printf("普通玩家");    

    }

    return 0;

}


1 回复 有任何疑惑可以回复我~

https://img1.sycdn.imooc.com//5c2dcca30001fa7a02090036.jpg,改为 else即可,后面去掉

0 回复 有任何疑惑可以回复我~

#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;


}


0 回复 有任何疑惑可以回复我~

你前面都是else if,那你最后一个用else就不恰当,也应该改为else if

0 回复 有任何疑惑可以回复我~

错误在最后【else (score < 1000)】,要写条件需要if(/* condition */)。

其实你的代码【if(score >= 10000){}else if(score >= 5000&&score < 10000)...】,  用else以后其实已经是满足score < 10000条件了,完全不用&&score < 10000了,直接else if(score >= 5000)即可,后面几个条件也是如此。

希望对你有帮助~~~

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
C语言入门
  • 参与学习       924176    人
  • 解答问题       20747    个

C语言入门视频教程,带你进入编程世界的必修课-C语言

进入课程

求解释求解释 没有错误啊 ?????

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信