代码演示:
#include <stdio.h>
int main()
{
int score;
printf("请输入成绩\n");
scanf("%d",&score);
switch(score/10){
case 1:
case 2:
case 3:
case 4:
case 5:
puts("等级为D");
break;
case 6:
case 7:
puts("等级为C");
break;
case 8:
case 9:
puts("等级为B");
break;
case 10:
puts("等级为A");
break;
default:
puts("成绩非法");
break;
}
puts("输入完毕");
return 0;
}
编译结果: