forked from ASD-ADF/ASD_Task_2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
102 lines (85 loc) · 2.49 KB
/
Main.cpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <iostream>
#include "list.h"
#include "operation.h"
using namespace std;
void mainMenu();
List L;
address P;
infotype X;
int main() {
createList(L);
//==================================================
// TEST INSERT FIRST
P = allocate(6);
insertFirst(L, P);
printInfo(L);
cout<<"output should be: 6,"<<endl;
insertFirst(L, allocate(3));
insertFirst(L, allocate(8));
printInfo(L);
cout<<"output should be: 8, 3, 6,"<<endl;
//==================================================
// TEST INSERT LAST
insertLast(L, allocate(4));
insertLast(L, allocate(2));
printInfo(L);
cout<<"output should be: 8, 3, 6, 4, 2,"<<endl;
//==================================================
// TEST INSERT AFTER
P = findElm(L, 6);
insertAfter(L, P, allocate(5));
printInfo(L);
cout<<"output should be: 8, 3, 6, 5, 4, 2,"<<endl;
//==================================================
// TEST DELETE FIRST
deleteFirst(L, P);
cout<<info(P)<<endl;
cout<<"output should be: 8"<<endl;
printInfo(L);
cout<<"output should be: 3, 6, 5, 4, 2,"<<endl;
deallocate(P);
//==================================================
// TEST DELETE LAST
deleteLast(L, P);
cout<<info(P)<<endl;
cout<<"output should be: 2"<<endl;
printInfo(L);
cout<<"output should be: 3, 6, 5, 4,"<<endl;
deallocate(P);
//==================================================
// TEST DELETE AFTER
address Prec = findElm(L, 6);
deleteAfter(L, Prec, P);
cout<<info(P)<<endl;
cout<<"output should be: 5"<<endl;
printInfo(L);
cout<<"output should be: 3, 6, 4,"<<endl;
deallocate(P);
//==================================================
// TEST DELETE ALL
deleteLast(L, P);
deallocate(P);
deleteFirst(L, P);
deallocate(P);
deleteLast(L, P);
deallocate(P);
printInfo(L);
cout<<"output should be: [empty]"<<endl;
//==================================================
// TEST INSERT SORTED
insert_sorted(L, 5);
printInfo(L);
cout<<"output should be: 5,"<<endl;
insert_sorted(L, 3);
insert_sorted(L, 8);
printInfo(L);
cout<<"output should be: 3, 5, 8,"<<endl;
insert_sorted(L, 5);
insert_sorted(L, 1);
insert_sorted(L, 5);
printInfo(L);
cout<<"output should be: 1, 3, 5, 8,"<<endl;
//==================================================
cout<<"CONGRATULATION, YOU'VE COMPLETED TASK 2 2019"<<endl;
return 0;
}