-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path72_b_Lists_STL.cpp
More file actions
69 lines (49 loc) · 1.24 KB
/
72_b_Lists_STL.cpp
File metadata and controls
69 lines (49 loc) · 1.24 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
60
61
62
63
64
65
66
67
68
69
// STL - Standard Template Libraries...!!
// Getting started with List !
#include<iostream>
#include<list>
using namespace std;
void display(list<int> &l){
list<int> :: iterator iter;
for (iter = l.begin(); iter != l.end(); iter++)
{
cout << *iter << " ";
}
cout << "\n\n";
}
int main()
{
list<int> list1; // List of 0 length
list1.push_back(5);
list1.push_back(7);
list1.push_back(1);
list1.push_back(9);
list1.push_back(9);
list1.push_back(12);
/*
SORTING THE LIST
list1.sort();
*/
display(list1);
// *****************************************************************************************************************************************************
list<int> list2(3); // Empty list of size 3.
list<int> :: iterator iter;
iter = list2.begin();
*iter = 45;
iter++;
*iter = 58;
iter++;
*iter = 69;
display(list2);
// MERGING THE ELEMENTS OF TWO LISTS...!!
list1.merge(list2);
list1.sort();
list2.sort();
cout << "list1 After merging: ";
display(list1);
// REVERSING THE ELEMENTS OF LISTS...!!
cout << "list1 After reversing: ";
list1.reverse();
display(list1);
return 0;
}