HUST Online Judge WebBoard
Problem 3978 >> 错误50%,实在不明白,求大佬解惑
202101030120 @ 2023-03-05 18:39:58
[ Quote ] [ Edit ] [ Delete ] 1#


```
#include<stdio.h>
#include<stdlib.h>
int main()
{
typedef struct node
{
int date;
struct node *next;
}stu;
stu *head1,*head2,*head3,*s,*r,*k;
int i=0,m,n,q,p;
head1=(stu *)malloc(sizeof(stu));
head2=(stu *)malloc(sizeof(stu));
head3=(stu *)malloc(sizeof(stu));
scanf("%d",&m);
r=head1;
for(i=0;i<m;i++)
{
s=(stu *)malloc(sizeof(stu));
scanf("%d",&s->date);
r->next=s;
r=s;
}
r->next=NULL;
scanf("%d",&n);
r=head2;
for(i=0;i<n;i++)
{
s=(stu *)malloc(sizeof(stu));
scanf("%d",&s->date);
r->next=s;
r=s;
}
r->next=NULL;
r=head3;
for(i=0;i<n+m;i++)
{
s=(stu *)malloc(sizeof(stu));
s->date=0;
r->next=s;
r=s;
}
r->next=NULL;
s=head3->next;
r=head1->next;
k=head2->next;
while(r&&k)
{
q=r->date;
p=k->date;
if(q<=p)
{
s->date=r->date;
s=s->next;
r=r->next;
}
if(q>p)
{
s->date=k->date;
s=s->next;
k=k->next;
}
}
while(r)
{
s->date=r->date;
s=s->next;
r=r->next;
}
while(k)
{
s->date=k->date;
s=s->next;
k=k->next;
}
r=head3->next;
for(i=0;i<m+n;i++)
{
printf("%d ",r->date);
r=r->next;
}
}

````