#include<stdio.h>
#include<stdlib.h>
typedef struct student
{
int xuehao;
char name[4];
int point1;
int point2;
int point3;
struct student *next;
}Linklists;
main()
{
void input(Linklists *head);
void print(Linklists *head);
void max(Linklists *head);
Linklists *head;
head=(Linklists*)malloc(sizeof(Linklists));
head->next=NULL;
input(head);
print(head);
max(head);
return 0;
}
void input(Linklists *head)
{
Linklists *p;
printf("请依次输入学号,姓名,各科成绩(学号输入00时结束):\n");
while(1)
{
p=(Linklists*)malloc(sizeof(Linklists));
scanf("%d",&p->xuehao);
if(p->xuehao==00)
{
free(p);
break;
}
scanf("%s %d %d %d",p->name,&p->point1,&p->point2,&p->point3);
p->next=head->next;
head->next=p;
}
}
void print(Linklists *head)
{
Linklists *p;
p=head->next;
printf("\n学号------姓名-------第一科成绩----第二科成绩----第三科成绩\n");
while(p!=NULL)
{
printf("%d %s %d %d %d\n",p->xuehao,p->name,p->point1,p->point2,p->point3);
p=p->next;
}
}
void max(Linklists *head)
{
Linklists *p=head->next;
int maxpoint,temp,maxxuehao;
maxxuehao=head->xuehao;
printf("最高分的同学的成绩如下:");
printf("\n学号------姓名-------第一科成绩----第二科成绩----第三科成绩\n");
while(p!=NULL)
{
maxpoint=p->point1+p->point2+p->point3;
p=p->next;
temp=p->point1+p->point2+p->point3;
if(maxpoint<temp)
{
maxxuehao=p->xuehao;
maxpoint=temp;
}
}
p=head->next;
while(p!=NULL)
{
if(maxxuehao==p->xuehao)
printf("%d %s %d %d %d\n",p->xuehao,p->name,p->point1,p->point2,p->point3);
else
p=p->next;
}
}