代码:
#include<iostream>
using namespace std;
int main()
{
string scoreGrade;//表示成绩分级
int score;
cout << "请输入您的成绩" << endl;
while (cin >> score && score >= 0 && score <= 100)
{
scoreGrade =
(score > 90) ? "high pass"
: (score > 75) ? "pass"
: (score >= 60) ? "lower pass" : "fail";
//这里使用的是条件运算符
cout << "您输入的成绩属于:" << scoreGrade << endl;
cout << "请输入您的成绩:" << endl;
}
return 0;
}
2021/6/17