#include<iostream>
using namespace std;
class Element
{
public:
int number;
Element *point;
};
Element *Init()
{
Element *curret,*first;
first=curret=new Element;
int count=0;
while(count<4)
{
cout<<"输入数据:";
cin>>curret->number;
curret=curret->point=new Element;
count++;
}
curret->point=NULL;
return first;
}
void print(Element *p)
{
Element *curret;
curret=p;
cout<<"\n全部的数据是:";
while(curret->point!=NULL)
{
cout<<curret->number<<" ";
curret=curret->point;
}
cout<<endl;
}
void function(Element *a,Element *b)
{
Element *Acurret,*Bcurret,*c,*temp,*lc;
Acurret=a->point;
Bcurret=b->point;
lc=c=a;
lc->point=NULL;
while(Acurret->point!=NULL && Bcurret->point!=NULL)
{
if(Acurret->number<Bcurret->number)
{
temp=Acurret->point;
Acurret->point=lc->point;
lc->point=Acurret;
Acurret=temp;
}
else
{
temp=Bcurret->point;
Bcurret->point=lc->point;
lc->point=Bcurret;
Bcurret=temp;
}
}
while(Bcurret->point!=NULL)
{
temp=Bcurret->point;
Bcurret->point=lc->point;
lc->point=Bcurret;
Bcurret=temp;
}
print(c->point);
}
void main()
{
Element *PA,*PB,*Ahead,*Bhead;
Bhead=Ahead=new Element();
PA=Init();
Ahead->point=PA;
cout<<"\nA链表输入完毕!\n\n";
PB=Init();
Bhead->point=PB;
cout<<"\nB链表输入完毕!\n";
print(PA);
print(PB);
function(Ahead,Bhead);
}
各位大哥大姐帮我看看这个程序错在哪里呢?谢谢!!!