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

2024-12-18 19:59:44
推荐回答(2个)
回答1:

#include
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");
}

回答2:

#include
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");
}