//有N个学生,每个学生的数据包括学号、姓名、3门课的成绩,从键盘输入N个学生的数据,要求打印出3门课的总平均成绩
#include <stdio.h>
struct student
{
char num[20];
char name[20];
int english;
int math;
int chinese;
};
void input(struct student p[],int N)
{ int i;
for(i=0;i<N;i++)
scanf("%c %c %d %d %d",p[i].num,p[i].name,&p[i].english,&p[i].math,&p[i].chinese);
}
void output(struct student p[],int N)
{
int e=0,m=0,c=0;
int i;
for(i=0;i<N;++i)
{
e = e + p[i].english;
m = m + p[i].math;
c = c + p[i].chinese;
}
printf("%d %d %d\n",e/N,m/N,c/N);
}
int main()
{
int i,N;
struct student p[20]; //最多20个学生
printf(“请输入您班级的学生数:”);
scanf("%d",&N);
input(p,N);
output(p,N);
return 0;
}