求大佬看看我这个代码哪里有问题
5 5
1 3 5 7 9
1 2 3 4 5
3 4
1 2 5
2 4 5 6
0 0
#include<iostream>
using namespace std;
#define OK 1
#define ORRER 2
typedef struct LNode
{
int data;
struct LNode *next;
}LNode,*Linklist;
int Init_LK(Linklist &L)
{
L=new LNode;
L->next=NULL;
return OK;
}
int Input_LK(Linklist &L,int length1)
{
for(int i=0;i<length1;i++)
{
Linklist p=new LNode;
cin>>p->data;
p->next=NULL;
L->next=p;
L=p;
}
return OK;
}
int main()
{
Linklist LA,LB;
Init_LK(LA);
Init_LK(LB);
int Len_A,Len_B;
while(cin>>Len_A>>Len_B&&Len_A!=0&&Len_B!=0)
{
Linklist headA=LA;
Linklist headB=LB;
Input_LK(LA,Len_A);
LA=headA;
// cout<<LA->next->data<<endl;
// cout<<LA->next->next->data<<endl;
Input_LK(LB,Len_B);
LB=headB;
Linklist p1=LA->next;
Linklist p2=LB->next;
Linklist p3=LA;
while(p1&&p2)
{
if(p1->data==p2->data)
{
p3->next=p1;
p3=p1;
p1=p1->next;
p2=p2->next;
}
if(p1->data<p2->data)
{
p1=p1->next;
}
else
{
p2=p2->next;
}
}
p3->next=NULL;
//delete LB;
cout<<"1"<<endl;
p1=LA->next;
while(p1->next)
{
cout<<p1->data<<" ";
p1=p1->next;
}
cout<<LA->data<<endl;
LA =headA;
}
return 0;
}