求助:关于一维数组的运用
程序运行可以通过,但是显示 Math[MAX]和Average[MAX]的值均为 0,不太明白,请大家帮我看看是哪里错了,谢谢!!#include<stdio.h>
#define MAX 50
void main()
{
int StuNum,i,Chinese[MAX],Math[MAX],English[MAX];
long StuID[MAX];
float Average[MAX],AverClass;
while(1)
{
printf("How many students are in your class?\n");
scanf("%d",&StuNum);
if(StuNum<1||StuNum>MAX)
{
printf("StudentNum must be between 1 and %d.Press any key to continue\n",MAX);
getch();
}
else
{
break;
}
}
printf("Please input a StudentID and three scores:\n");
printf(" StudentID Chinese Math English\n");
for(i=0;i<StuNum;i++)
{
printf("No.%d>",i+1);
scanf("%ld%d%d%d",&StuID[i],&Chinese[i],&Math[i],&English[i]);
Average[i]=(Chinese[i]+Math[i]+English[i])/3;
}
for(AverClass=0,i=0;i<StuNum;i++)
{
AverClass+=Average[i];
}
AverClass/=StuNum;
puts("\nStudentNum Chinese Math English Average");
puts("-------------------------------------------------");
for(i=0;i<StuNum;i++)
{
printf("%9ld %9d %9d %9d %9.1f\n",StuID[i],Chinese[i],Math[i],English[i],Average[i]);
}
puts("-------------------------------------------------");
printf("Average of the Class =%.2f\n",AverClass);
puts("Press any key to return");
getch();
}