为什么输出全是0
#include <stdio.h>
struct student
{
long num;
char name[20];
char sex;
float score1;
float score2;
float score3;
};
void ave(student *stu)
{
float sumScore[4];
sumScore[0] = 0;
sumScore[1] = 0;
sumScore[2] = 0;
for( int i = 0; i < 3; i++)
{
sumScore[0] += stu[i].score1;
sumScore[1] += stu[i].score2;
sumScore[2] += stu[i].score3;
}
for( int j = 1; j <= 3; j++)
{
printf("第%d门课的总成绩为%d",j,sumScore[j-1]);
printf("\n");
printf("第%d门课的平均成绩为%d",j,sumScore[j-1]/3);
printf("\n");
}
}
int main()
{
struct student stu[4]={{200601,"xiaoyi",'M',90,80,85},
{200602,"wangping",'M',80,85,84},
{200603,"huanghao",'M',70,75,75},
{200604,"zhaomei",'F',80,90,90}};
ave(stu);
return 0;
}