#include <stdio.h>
int main()
{
float score;
char grade;
printf("请输入学生成绩:");
scanf("%f",&score);
while (score>100||score<0)
{
printf("\n 输入成绩有误,请重试");
scanf("%f",&score);
}
switch((int)(score))
{
case 100:
case 90: grade='A';break;
case 80: grade='B';break;
case 70: grade='C';break;
case 60: grade='D';break;
case 50:
case 40:
case 30:
case 20:
case 10:
case 00: grade='E';break;
}
printf("成绩是 %5.1f,等级是 %c\n",score,grade);
return 0;
}
为什么这样的case出不来结果?
只能把score/10 case 100 90 80… 改成 case 10 9 8…才能出结果