帮我看看这错在哪
学习优良奖的条件如下:所考5门课的总成绩在450分(含)以上:或者每门课都在88分(含)以上。输入某学生5门课的考试成绩,输出是否够学习优良奖的条件。#include<stdio.h>
int main()
{
int a, i,k,j = 0, sum = 0;
for (i = 1; i <= 5; i++)
{
scanf_s("%d", &a);
sum += a;
if (a >= 88)
{
j += 1;
if (j == 5)
{
printf("The student is very good!");
}
else
{
printf("The student is not very good!");
}
}
}
if (sum >= 450)
{
printf("The student is very good!");
}
return 0;
}
输入:85 96 96 85 71
输出:The student is not very good! 本帖最后由 村里小黑 于 2021-11-18 14:54 编辑
#include<stdio.h>
int main()
{
int a, i,k,j = 0, sum = 0;
for (i = 1; i <= 5; i++)
{
scanf_s("%d", &a);
sum += a;
if (a >= 88)
{
j += 1;
if (j == 5)
{
printf("The student is very good!");
return 0;
}
}
}
if (sum >= 450)
{
printf("The student is very good!");
}
else
{
printf("The student is not very good!");
}
return 0;
}
你原来的代码判断的是a大于88的次数所以输出两次The student is not very good! 看不懂你说的错误在哪
页:
[1]