#include<stdio.h>
int main()
{
float g;
printf("请输入你的单科成绩:\n");
scanf("%f",&g);
if(g<0 || g>100)
printf("Score is error!");
else
{
switch((int)g/10)
{
case 10:
case 9:
printf("你的等级为A");
break;
case 8:
printf("你的等级为B");
break;
case 7:
printf("你的等级为C");
break;
case 6:
printf("你的等级为D");
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
printf("你的等级为E");
break;
default:printf("Score is error!");
break;
}
}
return 0;
}
C语言利用switch实现学生成绩等级换算
最新推荐文章于 2024-07-28 10:18:07 发布