1. 给出一百分制成绩,要求输出成绩等级‘优秀’、’良好’、’中等’、’及格’ 、’不及格’。其中90分以

作者&投稿:景费 (若有异议请与网页底部的电邮联系)
c语言题目:给出一百分制成绩,要求输出成绩等级‘A'、’B‘、'C'、‘D'、'E’。90分以上为A,80~89分为B,~

#include
int main()
{
int score, m;
scanf("%d", &score);
while (score 100){
printf("Error! Retry!
");
scanf("%d", &score);
}
m= score / 10;
if (m>= 9)
printf("Grade is A!
");
switch(m){
case 0: printf("Grade is E!
"); break;
case 1: printf("Grade is E!
"); break;
case 2: printf("Grade is E!
"); break;
case 3: printf("Grade is E!
"); break;
case 4: printf("Grade is E!
"); break;
case 5: printf("Grade is E!
"); break;
case 6: printf("Grade is D!
"); break;
case 7: printf("Grade is C!
"); break;
case 8: printf("Grade is B!
"); break;
}
return 0;
}

扩展资料:
其他实现输出成绩等级‘A'、’B‘、'C'、‘D'、'E’。90分以上为A,80~89分为B,70~79分为C,60~69分为D,60分一下为E的方法:
#include
int main()
{
int score;
scanf("%d", &score);
while (score 100){
printf("Error! Retry!
");
scanf("%d", &score);
}
if (score < 60)
printf("Grade is E!
");
else if (score >= 60 && score < 70)
printf("Grade is D!
");
else if (score >= 70 && score < 80)
printf("Grade is C!
");
else if (score >=80 && score < 90)
printf("Grade is B!
");
else
printf("Grade is A!
");
return 0;
}

假设成绩为x,看是输入还是读取文件啥的

if( x >= 60 && x < 70 )
{
printf("中等.
" );
}
else if( x >= 70 && x < 80 )
{
.......
}
写上一串if else 做

或者用switch来做
switch( x/10 )
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
printf( "不及格.
" );
break;
case 6:
...
break;
case 7:
...
break;
case 8:
...
break;
case 9:
case 10:
...
break;
defualt
...
break;

#include<stdio.h>
void main()
{
float score;
printf("输入分数:");
scanf("%f",&score);
if(score>=90 && score<=100)printf("优秀\n");
else if(score>=80)printf("良好\n");
else if(score>=70)printf("中等\n");
else if(score>=60)printf("及格\n");
else if(score>=0)printf("不及格\n");
else printf("error\n");
}

#include<stdio.h>
void main()
{
float score;
int flag;
printf("输入分数:");
scanf("%f",&score);
if(score>=90)flag=1;
if(score>=80&&score<=89)flag=2;
if(score>=70&&score<=79)flag=3;
if(score>=60&&score<=69)flag=4;
if(score<60)flag=5;
switch(flag)
{
case 1:printf("优秀");break;
case 2:printf("良好");break;
case 3:printf("中等");break;
case 4:printf("及格");break;
case 5:printf("不及格");break;
default:printf("error\n");
}
printf("\n");
}


绵竹市17777147569: c语言上机题,求大神1.给出一个百分制成绩,要求输出成绩等级A、B、C、D、E.90分以上为A,81 - 89分为B,70 - 79分为C,60 - 69分为D,60分以下为E.(第4... -
敞灵强肾:[答案] 第一题目:#includeint main(){ int num; scanf("%d",&num); if(num<...

绵竹市17777147569: 给出一个百分制成绩,要求输出成绩等级'A'、'B'、'C'、'D'、'E'.90分以上为'A',80~89分为'B -
敞灵强肾:[答案] 这不是switch语句的典型用法么,书上应该有现成的例子吧 #include using namespace std; int main() { \x09int n; \x09scanf("%d",&n); \x09while(n100) \x09{\x09cout

绵竹市17777147569: 1. 给出一个百分制成绩,要求输出成绩等级A、B、C、D和E.90分以上为A,89~80为B,79~70为C,69~60为D要详细的过程可以用if语句吗?还是非常感谢! -
敞灵强肾:[答案] #include using namespace std; void main(){ \x09coutscore; \x09while(score100){ \x09\x09coutscore; \x09} \x09switch(score/10){ \x09case 10: \x09case 9: \x09\x09cout

绵竹市17777147569: 程序题:给出一百分制成绩.用for语句和if语句写,给出一百分制成绩,要求输出成绩等级'A'、'B','C','D','E'.90分以上为'A',80~89为'B'... -
敞灵强肾:[答案] int num = 0; cout

绵竹市17777147569: C语言 给出一百分制成绩,要求输出成绩等级 -
敞灵强肾: 答void f1(int score) {int rate = score/10; switch(rate){case 10:putchar('A');break;case 9:putchar('A');break;case 8:putchar('B');break;case 7:putchar('C');break;case 6:putchar('D');break;default:putchar('E');}putchar('\n'); }

绵竹市17777147569: 给出一百分制成绩,要求输出成绩ABCDE,90分以上为A80~90为B,70~79为C,60~69为D,60一下为E -
敞灵强肾: 对于90<score<=100之类的表达式,无论SCORE取何值,在C语言中永远都会被认为是真的,所以你的程序只会输出A 在C语言中如果要表示90<score<=100这样的关系,应当写成90<score && score<=100,其它的几个也同样

绵竹市17777147569: 给出一百分制成绩,要求输出成绩等级'A','B','C','D','E'.90分以上为'A',80 - 89分为'B',70 - 79分为'C',60 - 69分为'D',60分一下为'E'.我知道这条题目要用switch来... -
敞灵强肾:[答案] 把你的成绩整除10不就可以了?! 如: 9X /10=9 8X /10=8 7X /10 =7 case 9://9x case 10://100 'A' break; case 8: 'B' break; case 7: 'C' break; case 6: 'D' break; default: 'E'

绵竹市17777147569: 给出一百分制成绩,要求输出成绩等级'A','B','C','D','E'.90分以上为'A',80~89分为'B',70~79分为'C',60~69分为'D',60分以下为... -
敞灵强肾:[答案] #includeusing namespace std;void main(){\x09coutscore;\x09while(score100){\x09\x09coutscore;\x09}\x09switch(score/10){\x09case 10:\x09case 9:\x09\x09cout

绵竹市17777147569: 给出一百分制成绩,要求输出成绩等级'A' 'B' 'C' 'D' 'E'.90分以上为'A',#include void main(){float score;scanf("%f",&score);switch(grade){case'A':printf("90... -
敞灵强肾:[答案] 你把switch中的因果关系弄反了,switch中的一般结构是case 常量表达式 : 语句,其中常量表达式是你输入的,而语句是执行部分,如果按照你那样会出现逻辑错误.#include void main(){int grade;float score;scanf("%f",&...

绵竹市17777147569: 1.给出一个百分制成绩,要求输出成绩等级A,B,C,D,E;90——100分为A,80——89为B; -
敞灵强肾: 可以用EXCEL来实现: 在Excel中,可这样完成 在A列中输入一些数值,如A1中为45,A2中为78,A3中为85,A4中为95;则在B列的对应单元格中显示D、B,C,A 以A1中数据为45为例,在B1中输入 =IF(A1>=90,"A",IF(A1>=80,"B",IF(A1>=60,"C","D"))) 输入后拖拉B1的复制句柄,(光标移到B1单元格的右下角,出现的细十字光标),复制公式到B2及需要的单元格.

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网