给出一百分制成绩,要求输出成绩等级‘A’、‘B’、‘C’、‘D’、‘E’。90分以上为‘A’,80~89分为‘B’,70~79分为‘C’,60~69为‘D’,60分以下为‘E’。
#include <stdio.h>
int main()
{
int score;
printf("Please enter score:");
scanf("%d",&score);
if(score<0||score>100)
printf("Input error!\n");
else
{
mark=score/10;
switch (mark)
{
case 10:
case 9: printf("%d--A\n",score); break;
case 8: printf("%d--B\n",score); break;
case 7: printf("%d--C\n",score); break;
case 6: printf("%d--D\n",score); break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0: printf("%d--E\n",score); break;
}
}
return 0;
}