编写程序,由键盘输入某位同学的百分制成绩,要求:

编写程序,由键盘输入某位同学的百分制成绩,要求:
(1)将其转换为等级制输出。转换标准是:90-100分,‘A’,80-89分,‘B’,70-79分,‘C’,60-69分,‘D’,60分以下,‘F’。
(2)如输入的成绩不在0-100之间,提示“输入错误!”。
西湖醋鱼999 1年前 已收到1个回答 举报

谁是谁的佛 幼苗

共回答了13个问题采纳率:84.6% 举报

#include "stdio.h"
#include "stdlib.h"
int main()
{
int score,level;
char band;
printf("Input Score:");
scanf("%d",&score);
if ( score > 100 || score < 0 )
{
printf("输入错误!n");
return 0;
}
level=score/10;
switch(level)
{
case 10:
case 9: band='A'; break;
case 8: band='B'; break;
case 7: band='C'; break;
case 6: band='D'; break;
default: band='F'; break;
}
printf("%d的等级为%cn",score,band);
system("pause");
return 0;
}

1年前

8
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.033 s. - webmaster@yulucn.com