-
Notifications
You must be signed in to change notification settings - Fork 0
/
list2.cpp
49 lines (47 loc) · 1.14 KB
/
list2.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
#include<iostream>
#include<list>
using namespace std;
void display(list<int> &l){
list<int> ::iterator itr;
for (itr=l.begin();itr!=l.end();itr++)
{
cout<<" ";
cout<<*itr<<"";
}
cout<<endl;
}
int main()
{
list<int>list1;
list1.push_back(34);
list1.push_back(31);
list1.push_back(56);
list1.push_back(98);
list1.push_back(2);
display(list1);
//** removing element from the list***
//list1.pop_back();//pop from back of the list
//list1.pop_front();//pop from the front
// list1.remove(76);//removing the element from the begining
// display(list1);
//sorting of the list*****
// list1.sort();
// display(list1);
// list<int>list2(3);
// list<int>::iterator itr;
// itr=list2.begin();
// *itr=56;
// itr++;
// *itr=98;
// itr++;
// *itr=14;
// display(list2);
//merging of the list***
// cout<<"list 1 after merging is ";
// list1.merge(list2);
// display(list1);
//for reversing the list***
//list1.reverse();
//display(list1);
return 0;
}