-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (34 loc) · 997 Bytes
/
main.cpp
File metadata and controls
47 lines (34 loc) · 997 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
#include <iostream>
// #include "include/List.hpp"
#include "include/SequenceList.hpp"
#include "include/LinkList.hpp"
#include "include/LinkQueue.hpp"
int main(int argc, char* argv[])
{
std::cout << "Now let us find sth interesting!" << std::endl;
int initSize = 20;
SequenceList<int> arr(initSize);
arr.insert(0, 1);
arr.insert(1, 2);
std::cout << "The length of arr is " << arr.length() << " !" << std::endl;
std::cout << "The element 1 is " << arr.search(1) << "th element in the arr !" << std::endl;
LinkList<int> arr2;
arr2.insert(0, 1);
// 1
arr2.clear();
LinkList<int> arr3;
arr3.insert(0, 3);
arr3.insert(1, 2);
arr3.insert(2, 5);
arr3.insert(3, 4);
arr3.insert(4, 7);
//3 2 5 4 7
std::cout << "right answer: 3 2 5 4 7." << std::endl;
arr3.traverse();
LinkQueue<int> queue;
queue.enQueue(1);
queue.enQueue(2);
std::cout << "Head =" << queue.getHead() << std::endl;
int value = queue.deQueue();
std::cout << "value =" << value << std::endl;
}