90分以上为’A’,80-89为’B’,70-79为’C’,60-69为’D’,60以下为’E’
#include<stdio.h>
int main(){
int score;
scanf("%d",&score); //遗漏了scanf的内容,显示为 D
if (score > 100 || score < 0) //遗漏了score不可小于0
printf("input error!");
if(score > 90)
printf("A");
else if(80 < score)
printf("B");
else if(70 < score)
printf("C");
else if(60 < 70)
printf("D");
else
printf("E");
return 0;
}
**
**
下面为switch语句的程序代码
#include<stdio.h>
int main(){
int score;
scanf("%d",&score);
if( score<0 || score>100)
printf("data error\n");
else switch(score/10){
case 9:printf("A"); break;
case 8:printf("B"); break;
case 7:printf("C"); break;
case 6:printf("D"); break;
default : printf("E");
}
return 0;
}