游客:  注册 | 登录 | 搜索 | 帮助
3s地带



标题: 给出一个百分制的成绩,要求按下列分数段输出成绩等级
hsrrcr1bx
狂风
Rank: 5Rank: 5Rank: 5



UID 7700
精华 0
积分 722
帖子 263
现金 712
贡献值 0
阅读权限 50
注册 2007-8-24
给出一个百分制的成绩,要求按下列分数段输出成绩等级
给出一个百分制的成绩,要求按下列分数段输出成绩等级(grade):90分以上为A, 80~89分为B, 70~79分为C, 60~69分为D, 其它分为E。


共有2处需要完善,分别被标识为(1),(2)。作题时请去掉这两个标识,在相应位置上填写适当内容,其它部分不得改动。


#include "stdio.h"
main()
{
int score;char ch;
scanf("%d",&score);
if( (1) )
ch='A';
else if(score>=80)
(2);
else if(score>=70)
ch='C';
else if(score>=60)
ch='D';
else
ch='E';
printf("The grade is: %c",ch);
getch();
}

改后的(不过也不好使):
#include "stdio.h"
main()
{
int score;char ch;

scanf("%d",&score);
if(score>=90)
ch='A';
else if(score>=80)
ch='B';
else if(score>=70)
ch='C';
else if(score>=60)
ch='D';
else
ch='E';
printf("The grade is: %c",ch);
getch();
}

我改的对不对呢?


还请各位大虾指点。

谢谢!!!!!

顶部
九王爷
疾风
Rank: 4Rank: 4



UID 7818
精华 0
积分 395
帖子 154
现金 385
贡献值 0
阅读权限 40
注册 2007-8-24

else if(score>=80) ch='B';
else if(score>=70) ch='C';
else if(score>=60)
改为
else if(score>=80 && score<90) ch='B';
else if(score>=70 && score<80) ch='C';
else if(score>=60 && score<70)
下面是完整的程序:
#include <stdio.h>
#include <conio.h>

void main()
{
int score;char ch;
scanf("%d",&score);

if(score>=90) ch='A';
else if(score>=80 && score<90) ch='B';
else if(score>=70 && score<80) ch='C';
else if(score>=60 && score<70) ch='D';
else ch='E';
printf("The grade is: %c",ch);
getch();
}

  
顶部


 
当前时区 GMT+8, 现在时间是 2009-1-9 15:00 清除 Cookies - 联系我们 - 3S地带 - Archiver - WAP - 赣ICP备07006302号
Powered by Discuz! 5.5.0  © Processed in 0.026695 second(s), 6 queries , Gzip enabled