#include<stdio.h>
#define SIZE 1
typedef struct student
{
int num;
int score[SIZE];
struct student *next;
}stu;
int main()
{
int t,k,n1,n2;
stu *head1=NULL,*head2=NULL,*p,*q,*i,*j,swap;
scanf(“%d”,&n1);
for(t=1;t<=n1;t++)
{
p=(stu *)malloc(sizeof(stu));
p->next=head1;
head1=p;
scanf(“%d”,&p->num);
for(k=0;k<SIZE;k++)
scanf(“%d”,&p->score[k]);
}
scanf(“%d”,&n2);
for(t=1;t<=n2;t++)
{
p=(stu *)malloc(sizeof(stu));
p->next=head2;
head2=p;
scanf(“%d”,&p->num);
for(k=0;k<SIZE;k++)
scanf(“%d”,&p->score[k]);
}
p=head1;
while(p->next!=NULL) p=p->next;
p->next=head2;
for(i=head1;i->next!=NULL;i=i->next)
for(j=i->next;j!=NULL;j=j->next)
{
if(i->num>=j->num)
{
swap=*j;
*j=*i;
*i=swap;
p=i->next;
i->next=j->next;
j->next=p;
}
}
p=head1;
while(p!=NULL)
{
printf(“%d “,p->num);
for(t=0;t<SIZE;t++)
printf(“%d “,p->score[t]);
printf(“n”);
q=p;
free(p);
p=q->next;
}
system(“pause”);
return 0;
}
0 条评论
沙发空缺中,还不快抢~