0

```
#include <iostream>
using namespace std;
struct TNode
{
int Data;
TNode *Next;
};
void PrintList (TNode *list);
TNode *AddData (TNode *list, int data);
void FreeList (TNode *list);
///////////////////////////////////////////////////////
void PrintList (TNode *list)
{
TNode *p;
for (p=list; p!=0; p=p->Next)
{
cout<<p->Data<<endl;
}
}
//////////////////////////////////////////////////////
TNode *AddData (TNode *list, int data)
{
TNode *newnode;
newnode= new TNode;
if (newnode ==0)
{
cout<<"Memory Failure"<<endl;
}
newnode->Next =list;
newnode->Data =data;
return newnode;
}
///////////////////////////////////////////////////////
int GetMax(TNode *list)
{
if (list==0)
{
return 0;
}
int max;
max= list-> Data;
TNode *p;
for (p=list;p!=0; p=p->Next)
{
if (max < p->Data)
{
max=p->Data;
}
}
return max;
}
///////////////////////////////////////////////////////////
TNode *ReverseList (TNode *list)
{
if (list==0)
{
return 0;
}
TNode *next;
TNode *newlist=0;
TNode *p;
for(p=list->Next; p!=0; p=next)
{
next= p->Next;
p->Next=newlist;
newlist=p;
}
return newlist;
}
////////////////////////////////////////////////////
void FreeList (TNode *list)
{
TNode *p;
TNode *Next;
for (p=list; p!=0; p=Next)
{
Next= p->Next;
delete p;
}
}
/////////////////////////////////////////////////////////////////
void GetOddEven (TNode *list, TNode*&oddlist, TNode*&evenlist)
{
TNOde *finallist;
TNode *p;
TNode *Next;
for (p=list; p!=0;p=Next)
{
Next =p->Next;
p->Next= finallist;
finallist = p;
if (finallist %2==1)
{
oddlist=finallist;
return oddlist;
}
else if (finallist %2==0)
{
evenlist=finallist;
return evenlist;
}
}
}
//////////////////////////////////////////////////////
int main (void)
{
TNode *list;
list= 0;
for (; ;)
{
int val;
cout<<"Enter #";
cin>>val;
if(val<=0)
{
break;
}
list = AddData (list, val);
}
PrintList(list); //////////Prints entered list
cout<<"Max="<<GetMax(list)<<endl;//////Prints largest entered number
list=ReverseList(list);
PrintList(list); /////Prints reversed list
TNode *oddlist;
TNode *evenlist;
cout<<GetOddEven(list,oddlist,evenlist)<<endl;
PrintList(list);
FreeList(list);
return 0;
}
```

**Okay there are several things going on in this program of mine. First I let numbers be entered then print out it as a list. Then I print out the largest number entered. After that I reverse the entered list. Now I'm trying to split the list into odd and even list. But I keep getting errors with my odd and even function. Can anyone help me?**