# include <iostream>
using namespace std;
typedef struct list
{
int data;
struct list * pNext;
} List, *pList;
pList CreatHeadNode ();
pList CreatNewNode ();
void BuildList (pList);
void PrintList (pList);
void ApartList (pList, pList);
int main ()
{
pList pHeada = CreatHeadNode ();
BuildList (pHeada);
// PrintList (pHeada);
pList pHeadb = CreatHeadNode ();
ApartList (pHeada, pHeadb);
PrintList (pHeada);
PrintList (pHeadb);
}
pList CreatHeadNode ()
{
pList pNewNode = new List;
pNewNode->data = 0;
pNewNode->pNext = NULL;
return pNewNode;
}
pList CreatNewNode ()
{
pList pNewNode = new List;
cin >> pNewNode->data;
if (pNewNode->data == 0)
return NULL;
pNewNode->pNext = NULL;
return pNewNode;
}
void BuildList (pList pHead)
{
pList pTail = pHead;
pList pNewNode = CreatNewNode ();
while (pNewNode)
{
pTail->pNext = pNewNode;
pTail = pNewNode;
pNewNode = CreatNewNode ();
}
}
void PrintList (pList pHead)
{
pList p = pHead->pNext;
while (p)
{
cout << p->data << " ";
p = p->pNext;
}
cout << "\n";
}
void ApartList (pList pHeada, pList pHeadb)
{
pList a = pHeada;
pList b = pHeadb;
while (a->pNext != NULL)
{
if (a->pNext->data%2 == 0)
{
b->pNext = a->pNext;
a->pNext = a->pNext->pNext;
b = b->pNext;
}
// a = a->pNext;
else
{
a = a->pNext;
}
}
b->pNext = NULL;
}