题目描述
给出一百分制成绩,要求输出成绩等级‘A’、‘B’、‘C’、‘D’、‘E’。 90分以上为A, 80-89分为B, 70-79分为C, 60-69分为D, 60分以下为E 。
将下面的程序填写完整。
#include <stdio.h>
int main()
{
int x;
while(scanf("%d",&x)!=EOF)
{ ........................
.........................
}
return 0;
}
输入
包含多组数据,每组一个0-100以内的一个整数。
输出
每个成绩对应一个字母,表示相应成绩等级。
样例输入
95
35
60
85
样例输出
A
E
D
B
提示
建议分别使用if语句的格式1、嵌套的if语句(if语句的格式3)和switch语句分别编写。
来源
hnldyhy
#include <stdio.h>
int main()
{
int x;
while(scanf("%d",&x)!=EOF)
{
if(x>=90)
printf("A\n");
if(x>=80&&x<89)
printf("B\n");
if(x>=70&&x<79)
printf("C\n");
if(x>=60&&x<69)
printf("D\n");
if(x<60)
printf("E\n");
}
return 0;
}