这是方法一,将两个链表先相连在排序
#include<stdio.h>
#include<malloc.h>typedef struct StudentType
{
int no;
int sub;
struct StudentType *next,*prior;
}*Linklist,Link;
Linklist Build(int n);
void Paixu(Linklist head,int n);
void Print(Linklist head);
int main()
{
int n,m;
Linklist head1=NULL,head2=NULL,head=NULL;
scanf("%d%d",&n,&m);
head1=Build(n);
head2=Build(m);
head1->prior->next=head2->next;
Paixu(head1,n+m);
Print(head1);
return 0;
}
Linklist Build(int n)
{
int i;
Linklist head=NULL,p=NULL,s=NULL;
head=(Linklist)malloc(sizeof(Link));
head->next=NULL;
p=head;
for(i=0;i<n;i++)
{
s=(Linklist)malloc(sizeof(Link));
scanf("%d%d",&s->no,&s->sub)