我的程序出了错误
不知道如何才能改正确。代码:
#include <stdio.h>
#define N 5
struct student
{int num;
char name[20];
float score[4];
}stu[N];
struct student *fuc(struct student *);
main()
{struct student *ps;
int i,j;
for(i=0;i<5;i++)
{scanf("%d",&stu[i].num);
gets(stu[i].name);
for(j=0;j<4;j++)
scanf("%f",&stu[i].score[j]);
}
ps=fuc(stu);
printf("num:%d ,name:%s ,score0:%f ,score1:%f ,
score2:%f ,score3:%f",ps->num,ps->name,ps->score[0],
ps->score[1],ps->score[2],ps->score[3]);
}
struct student *fuc(struct student *pt)
{int i,j,imax;
float max,sum;
max=0.0;
for(i=0;i<N;i++)
{sum=0.0;
for(j=0;j<4;j++)
sum+=pt[i].score[j];
if(sum>max)
{max=sum;imax=i;}
return(&stu[imax]);
}}