5.2 分别用if结构和switch结构编写程序分别用if结构和switch结构编写程序,对输入的一个百分制成绩,输出成绩的等级:90分以上为A等,80~89分为B等,70分~79分为C等,60~69分为D等,低于60分为E等.

来源:学生作业帮助网 编辑:六六作业网 时间:2024/04/27 20:58:08
5.2分别用if结构和switch结构编写程序分别用if结构和switch结构编写程序,对输入的一个百分制成绩,输出成绩的等级:90分以上为A等,80~89分为B等,70分~79分为C等,60~69分

5.2 分别用if结构和switch结构编写程序分别用if结构和switch结构编写程序,对输入的一个百分制成绩,输出成绩的等级:90分以上为A等,80~89分为B等,70分~79分为C等,60~69分为D等,低于60分为E等.
5.2 分别用if结构和switch结构编写程序
分别用if结构和switch结构编写程序,对输入的一个百分制成绩,输出成绩的等级:90分以上为A等,80~89分为B等,70分~79分为C等,60~69分为D等,低于60分为E等.

5.2 分别用if结构和switch结构编写程序分别用if结构和switch结构编写程序,对输入的一个百分制成绩,输出成绩的等级:90分以上为A等,80~89分为B等,70分~79分为C等,60~69分为D等,低于60分为E等.
main()
{
int score;
scanf("%d",&score);
switch(int(score/10))
{
case 10:
case 9: printf("Your score is A\n");break;
case 8: printf("Your score is B\n");break;
case 7: printf("Your score is C\n");break;
case 6: printf("Your score is D\n");break;
default: printf("Your score is E\n");
}
}
main()
{
int score;
scanf("%d",&score);
if(score>=90)
{printf("Your score is A\n");}
if(score>=80&&score=70&&score=60&&score