-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut64.cpp
More file actions
50 lines (43 loc) · 1.01 KB
/
tut64.cpp
File metadata and controls
50 lines (43 loc) · 1.01 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
#include<iostream>
#include<list>
using namespace std;
void display(list<int> &lst){
list<int> :: iterator it;
for ( it = lst.begin(); it!=lst.end(); it++)
{
cout<< *it<<" ";
}
cout<<endl;
}
int main(){
// 6, 8, 9
list<int> list1; //list of 0 length
//list<int> list2(7); //empty list of length 7 elements
list1.push_back(5);
list1.push_back(7);
list1.push_back(1);
list1.push_back(9);
list1.push_back(12);
display(list1);
// Removing items from a list
// list1.pop_front();
// list1.pop_back();
// list1.remove(9);
// display(list1);
// sorting a list
list1.sort();
display(list1);
list <int> list2(3);
list <int> :: iterator iter;
iter = list2.begin();
*iter = 45;
iter++;
*iter = 6;
display(list2);
list1.merge(list2);
cout<<"list 1 after merging with list2";
//Reversing the list
list1.reverse();
display(list1);
return 0;
}