#include<stdio.h>
#define N 3
typedef struct Student
{
int num;
char name[10];
int score[3];
float aver;
}Student;
void input(Student stu[]);
Student max(Student stu[]);
void print(Student stu[]);
int main()
{
Student stu[N];
Student *p=stu;
Student q;
input(p);
q=max(p);
/* printf("%d\n",q.score[1]); */
print(q);
/*printf("学号%d\n 姓名%s\n 三门成绩%d %d %d\n 平均分%0.2f\n",
q.num, q.name, q.score[0], q.score[1], q.score[2], q.aver); */
return 0;
}
void input(Student stu[])
{
int i;
for(i=0;i<3;i++)
{
scanf("%d %s %d %d %d",&stu[i].num,stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);
stu[i].aver=(stu[i].score[0]+stu[i].score[1]+stu[i].score[2])*1.0/3;
}
/* printf("%d\n",stu[2].score[1]); */
}
Student max(Student stu[])
{
int i,m=0;
for(i=0;i<N;i++)
{
if(stu[i].aver>stu[m].aver) m=i;
}
/*printf("%d\n",stu[m].score[1]); */
return stu[m];
}
void print(Student stud)
{
printf("成绩最高的同学是:\n");
printf("学号%d\n 姓名%s\n 三门成绩%0.2f %0.2f %0.2f\n 平均分%0.2f\n",
stud.num,stud.name,stud.score[0],stud.score[1],stud.score[2],
stud.aver);
}
c:\users\初晨陌夜\desktop\s.cpp(24) : error C2664: 'print' : cannot convert parameter 1 from 'struct Student' to 'struct Student []' 求指教