程序填空题:输出成绩等级
给出一百分制成绩,要求输出成绩等级。90分及以上为'A',80~89为'B',70~79为'C',60~69为'D',60分以下为'E'。
c++
#include <stdio.h>
int main()
{
float score;
char grade;
scanf("%f",&score);
while ()
{
printf("\n 输入有误,请重输");
scanf("%f",&score);
}
switch()
{
case 10:
case 9: grade='A';break;
case 8: grade='B';break;
case 7: grade='C';break;
case 6: grade='D';break;
case 0: grade='E';
}
printf("%c\n",grade);
return 0;
}
答案:
第1空:score>100 || score<0
第2空:(int)(score/10)
第3空:case 5:
case 4:
case 3:
case 2:
case 1:
c++
#include <stdio.h>
int main()
{
float score;
char grade;
scanf("%f",&score);
while ()
{
printf("\n 输入有误,请重输");
scanf("%f",&score);
}
switch()
{
case 10:
case 9: grade='A';break;
case 8: grade='B';break;
case 7: grade='C';break;
case 6: grade='D';break;
case 0: grade='E';
}
printf("%c\n",grade);
return 0;
}
答案:
第1空:score>100 || score<0
第2空:(int)(score/10)
第3空:case 5:
case 4:
case 3:
case 2:
case 1: