#include<stdio.h>
struct student{ /*学生信息结构定义*/
int num; /*学号*/
char name[10]; /*姓名*/
int computer,english,math; /*三门课程成绩*/
double average; /*个人平均成绩*/
};
int main(void)
{
int i,n;
struct student max,stu; /*定义结构变量*/
printf("Input n:"); /*提示输入人数*/
scanf("%d",&n);
printf("Input the student's number,name and course scores\n");
for(i=1;i<=n;i++){
printf("NO.%d:",i); /*输入第一个学生成绩*/
scanf("%d%s%d%d%d",&stu.num,stu.name,&stu.math,&stu.english,&stu.computer);
stu.average=(stu.math+stu.english+stu.computer)/3.0;
if(i==1){
max=stu;
}else if(max.average<stu.average){
max=stu;
}
}
printf("num:%d,name:%s,average:%.21f\n",max.num,max.name,max.average);
return 0; /*结束语句*/
}
![](https://i-blog.csdnimg.cn/blog_migrate/62b38555185055e94d466068e383d15a.png)