-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path64lists.cpp
More file actions
59 lines (53 loc) · 1.18 KB
/
Copy path64lists.cpp
File metadata and controls
59 lines (53 loc) · 1.18 KB
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
#include <iostream>
#include <cstring>
#include <fstream>
#include <list> // header file to include for list container
using namespace std;
template <class T>
void display(list<T> &l)
{
cout << "LIST ELEMENTS !!" << endl;
list<int>::iterator it;
for (it = l.begin(); it != l.end(); it++)
{
cout << *it << " ";
}
cout << endl;
}
int main()
{
list<int> list1; // zero length empty list
list1.push_back(6);
list1.push_back(2);
list1.push_back(1);
list1.push_back(3);
list1.push_back(34);
list1.push_back(4);
list1.push_back(324);
display(list1);
list<int> tsil(3);
list<int>::iterator it2 = tsil.begin();
*it2 = 3;
it2++;
*it2 = 7;
it2++;
*it2 = 8;
it2++;
display(tsil);
// Pop function to delete elements from the front
list1.pop_front();
display(list1);
// Function to remove a particular element from the list
list1.remove(4);
display(list1);
// function to merge 2 lists
list1.merge(tsil);
display(list1);
// function to sort the list
list1.sort();
display(list1);
// reversing a list function
list1.reverse();
display(list1);
return 0;
}