C/C++编程学习 - 第22周 ⑥ 分数评级

题目链接

题目描述

程序读入一个整数S,作为一个学生的期末成绩,请你输出他的成绩评级。

评级规则:
A级:90 <= S <= 100,B级:80 <= S < 90,C级:70 <= S < 80,D级:60 <= S < 70,E级:0 <= S < 60。

Input
输入一个数S,表示该学生的分数

Output
输出一个大写字母,表示学生成绩的评级

Sample Input

72

Sample Output

C

思路

按照题目给的级别,输入一个分数,输出对应的级别。

C++代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
	int s;
	while(cin >> s)
	{
    
    
		if(90 <= s && s <= 100) cout << "A" << endl;
		else if(80 <= s && s <= 90) cout << "B" << endl;
		else if(70 <= s && s <= 80) cout << "C" << endl;
		else if(60 <= s && s <= 70) cout << "D" << endl;
		else if(0 <= s && s <= 60) cout << "E" << endl;
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_44826711/article/details/113572648
今日推荐