-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_test.cpp
More file actions
49 lines (37 loc) · 815 Bytes
/
split_test.cpp
File metadata and controls
49 lines (37 loc) · 815 Bytes
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
#include "split.h"
#include <iostream>
using namespace std;
void deleteLists(Node* in);
int main(int argc, char* argv[])
{
//Create head pointer
Node* initial = new Node(1, nullptr);
Node* init_head = initial;
int i = 2;
while(i<=100){
initial->next = new Node(i, nullptr);
initial = initial->next;
i+=3;
}
Node* evens = nullptr;
Node* odds = nullptr;
cout << "initial list ( initial :-) ): ";
printLists(init_head);
split(init_head, odds, evens);
cout << "initial list ( final ): ";
printLists(init_head);
cout << "odds:";
printLists(odds);
cout << "evens:";
printLists(evens);
deleteLists(evens);
deleteLists(odds);
return 0;
}
void deleteLists(Node* in){
while(in != nullptr){
Node* temp = in->next;
delete in;
in = temp;
}
}