实在看不懂那个地方错了,希望各位指点迷津啊!
题目是:n个人,m个课程,求每人总成绩和某门课程总分数!谢谢各位啊#include <stdio.h>
#define M 10
#define N 3
int score[M][N]
int student_sum(int i)
{ int j,sum=0;
for(j=0;j<N;j++)
sum=sum+score[i][j];
return(sum);
}
int course_sum(int j)
{
int i,sum=0;
for(i=0;i<M;i++)
sum=sum+score[i][j];
return(sum);
}
void main()
{int i,j;
int score[M][N],student_sum,course_sum;
for (i=0;i<M;i++)
{printf("please input all the students' grades of no. %d :",i+1);
for (j=0;j<N;j++)
scanf("%d",&score[M][N]);}
printf("all of the grades:\n");
for (i=0;i<M;i++)
{for (j=0;j<N;j++)
printf("%5d",score[i][j]);
printf("\n");}
printf("please input the student_sum:\n");
for (i=0;i<M;i++)
{student_sum(i);
printf("%5d",student_sum);}
printf("please input the course_sum:\n");
for (j=0;j<N;j++)
{course_sum(j);
printf("%5d",course_sum);}
}
[ 本帖最后由 孤独微积分 于 2011-3-20 23:05 编辑 ]