38. 成绩等级
语法讲解
今天学: 用多个 else if 实现区间分类。
#include <iostream>
using namespace std;
int main() {
int s;
cin >> s;
if (s >= 90) {
cout << "A" << endl;
} else if (s >= 80) {
cout << "B" << endl;
} else if (s >= 60) {
cout << "C" << endl;
} else {
cout << "D" << endl;
}
return 0;
}
小练习
输入 85,输出是什么?
输入: 85
提交要求: 只提交最终输出结果,不要添加多余的说明或引号。
全部评论