#include <iostream>//compare.cpp
#include "Node.h"
#include "SimpleLinkList.h"
using namespace std;
template<class ElemType>
void oppositedSequence(SimpleLinkList<ElemType> &lc)
{
int atemp;
int btemp;
int length=lc.Length();
for(int i=1;i<=(int)(length/2);i++)
{
lc.GetElem(i,atemp);
lc.GetElem(length-i+1,btemp);
lc.SetElem(i,btemp);
lc.SetElem(length-i+1,atemp);
}
}
template<class ElemType>
void MergeList(SimpleLinkList<ElemType> &la,SimpleLinkList<ElemType> &lb,SimpleLinkList<ElemType> &lc)
{
int aLength=la.Length(),bLength=lb.Length(),aPosition=1,bPosition=1;
ElemType aItem,bItem,cItem;
while(aPosition<=aLength&&bPosition<=bLength)
{
la.GetElem(aPosition,aItem);
lb.GetElem(bPosition,bItem);
if((!lc.Exist(aItem))&&(!lc.Exist(bItem)))
{
if(aItem<=bItem)
{
lc.Insert(lc.Length()+1,aItem);
lc.Insert(lc.Length()+1,bItem);
}
else
{
lc.Insert(lc.Length()+1,bItem);
lc.Insert(lc.Length()+1,aItem);
}
}else if(lc.Exist(aItem)&&lc.Exist(bItem))
{
}else if(lc.Exist(aItem))
{
lc.Insert(lc.Length()+1,bItem);
}
else
{
lc.Insert(lc.Length()+1,aItem);
}
aPosition++;
bPosition++;