help with splitevensoddlist

Also write the definition of the function splitEvensOddsList. Note that this function does not create any new node, it only rearranges the nodes of the original list so that nodes with even integers are in evensList and nodes with odd integers are in oddsList. i do not think im doing this right could some please help me i think it wrong to be honest

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
template <class Type>
class intLinkedList: public unorderedLinkedList<Type>
{
    public:
        void  splitEvensOddsList(intLinkedList  &evensList,intLinkedList  &oddsList);

};
template <class Type>
void intLinkedList<Type>::splitEvensOddsList(intLinkedList  &evensList,intLinkedList  &oddsList)
{
    *oddsList = *evensList = NULL;

    nodeType<Type> *oddTrail;
    nodeType<Type> *evenTrail;
    nodeType<Type> *head;
    if(head ==NULL)
    {
        return;
   }
      else

	     {
	         nodeType<Type> * iteratorr = head;
	         while( iteratorr!= NULL )
                {
                    if( iteratorr->info % 2 == 0 )
                    {
                        if( *evensList == NULL )
                        {
                            *evensList = evenTrail = iteratorr;
                        }
                        else
                        {
                            evenTrail->link = iteratorr;
                            evenTrail = iteratorr;
                        }
                        }
                        else
                            {
                                if( *oddsList == NULL )

	                         {
	                             *oddsList = oddTrail = iteratorr;

                             }
                             else
                                   {
                                    oddTrail->link = iteratorr;
                                    oddTrail= iteratorr;
                                    }
                               }
                                nodeType<Type> * nextNode = iteratorr->next;
                                iteratorr->link = NULL;
                                iteratorr = nextNode;

	         }

	     }
}
i got the number to print function to work and set up my numbers the way i want them too but i just think im doing this function in general i know how to make a basic program for even and odd ,but i just think im doing this wrong in general
Topic archived. No new replies allowed.