1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using std::cout;
using std::cin;
int main() {
int score = 0;
char rank = '?';
while (1) {
cout << "input score(0-100) > ";
cin >> score;
if (!cin.fail()) break;
cin.clear();
cin.ignore(10000, '\n');
}
if (score >= 0 && score <= 100) {
if (score < 60) rank = 'D';
else if (score < 80) rank ='C';
else if (score < 90) rank = 'B';
else rank = 'A';
}
cout << "your rank is [" << rank << "]" << std::endl;
return 0;
}