二维数组,求帮助
不知道错在哪里,新手,求大虾帮助,谢谢!#include<stdio.h>
#define STUD_N 40
#define COURSE_N 3
int ReadScore(long num[],int score[][COURSE_N]);
void AverForCourse(int score[][COURSE_N],int sum[],float aver[],int n);
void AverForStud(int score[][COURSE_N],int sum[],float aver[],int n);
void Print(long num[],int score[][COURSE_N],int sumC[],float averC[],int sumS[],float averS[],int n);
int main()
{
int n,sumC[COURSE_N],sumS[STUD_N],score[STUD_N][COURSE_N];
float averC[COURSE_N],averS[STUD_N];
long num[STUD_N];
n=ReadScore(num,score);
AverForCourse(score,sumC,averC,n);
AverForStud(score,sumS,averS,n);
Print(num,score,sumC,averC,sumS,averS,n);
return 0;
}
int ReadScore(long num[],int score[][COURSE_N])
{
int i,j,n;
printf("Input the total students number of the students:");
scanf("%d",&n);
printf("Input the student's ID and score as :MT EH PH:\n");
for(i=0;i<=n;i++)
{
scanf("%ld",&num[i]);
for(j=0;j<COURSE_N;j++)
{
scanf("%d",score[i][j]);
}
return i;
}
void AverForCourse(int score[][COURSE_N],int sum[],float aver[],int n)
{
int i,j;
for(i=0;i<=n;i++)
{
sum[i]=0;
for(j=0;j<=COURSE_N;j++)
{
sum[i]=sum[i]+score[i][j];
}
aver[i]=float(sum[i])/n;
}
}
void AverForStud(int score[][COURSE_N],int sum[],float aver[],int n)
{
int i,j;
for(j=0;j<=n;j++)
{
sum[j]=0;
for(i=0;i<=COURSE_N;i++)
{
sum[j]=sum[j]+score[i][j];
}
aver[j]=float(sum[j])/n;
}
}
void Print(long num[],int score[][COURSE_N],int sumC[],float averC[],int sumS[],float averS[],int n)
{
int i,j;
printf("Counting Result:\n");
printf("Student's ID:\t MT \t EH \t PH \t");
for(i=0;i<=n;i++)
{
printf("%12ld",num[i]);
for(j=0;j<=COURSE_N.;j++)
{
printf("\t%4d\t",score[i][j]);
}
printf("%4d\t%4.1f\n",sumS[i],averS[i]);
}
}