在做教材例题时遇到报错,照着教材打代码也解决不了,不知道哪里错了,题目是编程计算学生及课程的总分和平均分
#include <stdio.h>
#define STUD_N 40
#define COURSE_N 3
void ReadScore(int score[][COURSE_N],long num[],int n);
void AverforStud(int score[][COURSE_N],int sum[],float aver[],int n);
void AverforCourse(int score[][COURSE_N],int sum[],float aver[],int n);
void Print(int score[][COURSE_N],long num[],int sumS[],
float averS[],int sumC[],float averC[],int n);
int main()
{
int score[STUD_N][COURSE_N],sumS[STUD_N],sumC[COURSE_N],n;
long num[STUD_N];
float averS[STUD_N],averC[COURSE_N];
printf("input total number of students:");
scanf("%d",&n);
ReadScore(score,num,n);
AverforStud(score,sumS,averS,n);
AverforCourse(score,sumC,averC,n);
Print(score,num,sumS,averS,sumC,averC,n);
return 0;
}
void ReadScore(int score[][COURSE_N],long num[],int n)
{
int i,j;
printf("input student's ID and scores as MT EN PH:\n");
for(j=0;j<n;j++)
{
scanf("%10d",&num[j]);
for(i=0;i<COURSE_N;i++)
{
scanf("%d",&score[j][i]);
}
}
}
void AverforStu(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]/COURSE_N;
}
}
void AverforCourse(int score[][COURSE_N],int sum[],float aver[],int n)
{
int i,j;
for(i=0;i<COURSE_N;i++)
{
sum[i]=0;
for(j=0;j<n;j++)
{
sum[i]=sum[i]+score[j][i];
}
aver[i]=(float)sum[i]/n;
}
}
void Print(int score[][COURSE_N],long num[],int sumS[],
float averS[],int sumC[],float averC,int n)
{
int i,j;
printf("Students'ID\t MT\t EN\t PH\t SUM\t AVER\n");
for(i=0;i<n;i++)
{
printf("%12ld\t",num[i]);
for(j=0;j<COURSE_N;j++)
{
printf("%4d\t",score[i][j]);
}
printf("%4d\t%5.1f\n",sumS[i],averS[i]);
}
printf("SumofCourse\t");
for(j=0;j<COURSE_N;j++)
{
printf("%4d\t",sumC[j]);
}
printf("\nAverofCourse\t");
for(j=0;j<COURSE_N;j++)
{
printf("%4.1f\t",averC[j]); //这一行报错但是我不知道哪里有问题
}
printf("\n");
}
[Error] invalid types 'float[int]' for array subscript