一开始将n/10划分为了E,但-10<n<0就也被归类到E中,导致出现错误。
#include <stdio.h>
int main() {
int n;
while(scanf("%d",&n)!=EOF) {
switch(n/10){
case 10:
case 9:
printf("A\n");
break;
case 8:
printf("B\n");
break;
case 7:
printf("C\n");
break;
case 6:
printf("D\n");
break;
case 5:
case 4:
case 3:
case 2:
case 1:
printf("E\n");
break;
default:
if(n>=0&&n<10) {
printf("E\n");
break;
}
printf("Score is error!\n");
}
}
return 0;
}