1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <math.h> 4 int main() 5 { 6 int score; 7 scanf("%d",&score); 8 if(score>100||score<0) 9 { 10 printf("输入错误,请重新输入:"); 11 scanf("%d",&score); 12 } 13 switch((int)score/10) //分数整除后强制转换为整数 14 { 15 case 10: 16 case 9: printf("grade = A"); break; 17 case 8: printf("grade = B"); break; 18 case 7: printf("grade = C"); break; 19 case 6: printf("grade = D"); break; 20 case 5: 21 case 4: 22 case 3: 23 case 2: 24 case 1: 25 case 0: printf("grade = E"); break; 26 27 } 28 29 return 0; 30 }