如果是是求每一科的平均分
,上面的程序改一点就可以,不用我再说了吧
struct student
{
float score;}stu[15][10]={{45,44,67,68,70,45,88,99,55,78},{55,44,67,68,70,45,88,99,55,78},{87,44,67,68,70,45,88,99,55,78},{94,44,67,68,70,45,88,99,55,78},{78,44,67,68,70,45,88,99,55,78},{58,44,67,68,70,45,88,99,55,78},{99,44,67,68,70,45,88,99,55,78},{77,44,67,68,70,45,88,99,55,78},{89,44,67,68,70,45,88,99,55,78},{67,44,67,68,70,45,88,99,55,78},{34,44,67,68,70,45,88,99,55,78},{22,44,67,68,70,45,88,99,55,78},{60,44,67,68,70,45,88,99,55,78},{40,44,67,68,70,45,88,99,55,78},{75,44,67,68,70,45,88,99,55,78}
};
#include<stdio.h>
main()
{
void ave(struct student stu[],int n);
ave(stu,15);
}
void ave(struct student stu[][10],int n)
{
int c=0;
int i,j;
float ave,s=0;
for(i=0;i<n;i++)
{ for(j=0;j<10;j++){
s+=stu[i][j].score;
}
ave=s/15;
printf("average=%f\n",ave);
}