#include <iostream>
#include <stdlib.h>
using namespace std;
int main(void)
{
int x;
cout << "请输入该名同学的成绩" << endl;
for (;;)
{
cin >> x;
if (x>100||x<0)
{
cout << "您输入的成绩不合法,请重新输入" << endl;
continue;
}
else break;
}
x = x / 10;
switch (x)
{
case 9:case 10:cout << "该名同学的成绩等级为A" << endl; break;
case 8:cout << "该名同学的成绩等级为B" << endl; break;
case 7:cout << "该名同学的成绩等级为C" << endl; break;
case 6:cout << "该名同学的成绩等级为D" << endl; break;
default:cout << "该名同学的成绩等级为E" << endl; break;
}
system("pause");
return 0;
}
C/C++:switch语句
最新推荐文章于 2022-10-20 23:23:33 发布