c语言 输入一个学生成绩,判断优、良、及格?

2024-12-03 06:16:27
推荐回答(5个)
回答1:

#include
int main()
{
int nscore = 0;
scanf("%d",&nscore);
if ( nscore > 90 )
{
printf("成绩优!\n");
}
else if ( nscore > 80 )
{
printf("成绩良!\n");
}
else if ( nscore > 60 )
{
printf("成绩及格!\n");
}
else
{
printf("成绩不及格!\n");
}

return 0;
}

回答2:

#include
#include
int main()
{
while(1)
{

int n = 0;
printf("输入成绩(-1退出):");
scanf("%d",&n);
if(n == -1)
{
return 0;
}
switch(n/10)
{
case 6:
printf("及格\n");
break;
case 7:
printf("中等\n");
break;
case 8:
printf("良好\n");
break;
case 9:
case 10:
printf("优秀\n");
break;
default:
printf("不及格\n");
break;
}
}
return 0;
}

回答3:

#include
int main()
{
int score;
printf("请输入分数:\n");
scanf("%d",&score);
switch(score/10){
case 10:
case 9:
printf("成绩为优秀!\n");
break;
case 8:
printf("成绩为良!\n");
break;
case 7:
case 6:
printf("成绩为合格!\n");
break;
default:
printf("对不起,你的成绩不合格!\n");
}
}

回答4:

1 #include
2
3 int main()
4 {
5 while(1)
6 {
7 int num;
8 printf("input a scores:");
9 scanf("%d", &num);
10
11 if (num >= 80)
12 {
13 printf("良\n");
14 }
15 else if (num <= 80 && num >= 60)
16 {
17 printf("及格\n");
18 }
19 else if (num <60)
20 {
21 printf("不及格\n");
22 }
23 else
24 {
25 break;
26 }
27 }
28 }
~
~

回答5:

#include
void main()
{
int score ;
scanf("%d",&score);
if ( score > 90 )
{
printf("成绩优秀\n");
}
else if ( score > 80 )
{
printf("成绩良好\n");
}
else if ( score > 60 )
{
printf("成绩及格\n");
}
else
{
printf("成绩不及格\n");
}
}