#include <iostream>
using namespace std;
int main()
{
int grade;
int value;
cin >> grade;
if (90 <= grade && grade <=100) value = 0;
else if (80 <= grade && grade <90) value = 1;
else if (70 <= grade && grade <80) value = 2;
else if (60 <= grade && grade <70) value = 3;
else if (0 <= grade && grade <60) value = 4;
else value = -1;
switch (value)
{
case 0: cout << "grade is A" << endl;
break;
case 1: cout << "grade is B" << endl;
break;
case 2: cout << "grade is C" << endl;
break;
case 3: cout << "grade is D" << endl;
break;
case 4: cout << "grade is E" << endl;
break;
default: cout << "grade is invalid" << endl;
break;
}
}
C++ switch语句
最新推荐文章于 2024-04-10 19:00:00 发布