怎么能实现那个 input 函数想要达到输入的目的呢?哪位大神可以帮帮忙呢
#include<stdio.h>#define N 3
struct Student
{
int num;
char sex;
char name[20];
float score[4];
float aver;
};
int main()
{
void input(struct Student stu[]);
struct Student max(struct Student stu[]);
void print(struct Student stu);
struct Student stu[N],*p=stu;
input(p);
print(max(p));
return 0;
}
void input(struct Student stu[])
{
int i;
for(i=0; i<N; i++)
{
scanf("%d%s%f%f%f%f",&stu[i].num,&stu[i].sex,&stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2],&stu[i].score[3]);
stu[i].aver = (stu[i].score[0]+stu[i].score[1]+stu[i].score[2]+stu[i].score[3])/4.0;
}
}
struct Student max(struct Student stu[])
{
int i,m = 0;
for(i = 0; i<N; i++)
if(stu[i].aver>stu[m].aver)
m=i;
return stu[m];
}
void print(struct Student stu)
{
printf("\n成绩最高的学生是:\n");
printf("学号:%d\n性别:%s\n姓名:%s\n四门课成绩:%f%f%f%f\n平均成绩:%6.2f\n",stu.num,stu.sex,stu.name,stu.score[0],stu.score[1],stu.score[2],stu.score[3],stu.aver);
}