写完之后发现根本就不用switch,用if else的话反而更简洁。。。 #include <stdio.h> int main() { int a,b; while( scanf("%d",&a)!=EOF ) { if (a<=100 && a>=90) b=1; else if (a<=89 && a>= 80) b=2; else if (a<=79 && a>= 70) b=3; else if (a<=69 && a>= 60) b=4; else if (a<=59 && a>= 0) b=5; else b=6; switch(b) { case 1: printf("A/n"); break; case 2: printf("B/n"); break; case 3: printf("C/n"); break; case 4: printf("D/n"); break; case 5: printf("E/n"); break; case 6: printf("Score is error!/n"); break; } } return 0; }