struct course
{
int grade;
};
struct student
{
struct course cou[5];
};
main()
{
int i=0,j=0;
int sum1[2]={0,0};
float avg1[2]={0,0};
struct student stu[2];
for(i=0;i<2;i++)
{
for(j=0;j<5;j++)
scanf("%d",&stu[i].cou[j].grade);
if(j==5)
printf("\n");
}
i=0;
while(i<2)
{
for(j=0;j<5;j++)
sum1[i]=sum1[i]+stu[i].cou[j].grade;
avg1[i]=1.0*sum1[i]/5;
i++;
}
for(i=0;i<2;i++)
printf("avg1[%d]=%f\n",i,avg1[i]);
}
如何学生avg独立写成一个函数啊???