题解 | #判断成绩等级#

判断成绩等级

https://www.nowcoder.com/practice/1a12e246764243ada9043699b9a1e7ef

#include <iostream>
using namespace std;

int main() {
    
    int score;
    cin >> score;

    // write your code here......
    if(score>=0&&score<=100)  
        cout<<((score>=0&&score<60)?"差":
        (score>=60&&score<70)?"及格":
        (score>=70&&score<80)?"中":
        (score>=80&&score<90)?"良":
        (score>=90&&score<=100)?"优秀":"")<<endl;
    else 
        cout<<"成绩不合法"<<endl;
    
    return 0;
}

连续三个题都可以用三目运算符求解,不知道这么依赖三目会不会不好

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务