回复 2楼 voidx
我是这么写的但是不让运行。。。。哪错了啊。。。。
#include <stdio.h>
#define N 10
struct stu_info
{int num;
char name [10];
int score [3];
int total;
float aver;
}
stu [N];
void input()
{
int i;
for (i=0;i<N;i++)
{printf ("inupt the %d student xuehao, xingming ,3menkedechengji:\n",i+1);
scanf ("%d%s%d%d%d",&stu[i].num,&stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);
}
}
float average ()
{
int i;
float ave=0.0;
for (i=0;i<N;i++)
{stu[i].total=stu[i].score[0]+stu[i].score[1]+stu[i].score[2];
stu [i].aver=stu [i].total/3.0;
ave +=stu[i].aver;
}
return ave;
}
void maximum (struct stu_info*maxstu)
{
int i;
*maxstu=stu[0];
for (i=1;i<N;i++)
if (maxstu->total<stu[i].total)
*maxstu=stu[i];
}
int main()
{
struct stu_info maxstu;
float Average;
int i;
inupt ();
printf ("NO. name score1 score2 score3 total average\n");
Average=average();
for (i=0;i<N;i++)
printf ("%-8d%-8s%-5d%8d%8d%8d%8.2f\n",stu[i].num,stu[i].name,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].total,stu[i].aver);
printf ("Average=%.2f\n",Average);
maximum (&maxstu);
printf ("The highest score: %s,scoretotal:%d\n",maxstu.name,maxstu.total);
return 0;
}