-
Notifications
You must be signed in to change notification settings - Fork 2
/
36.cpp
55 lines (48 loc) · 978 Bytes
/
36.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
50
51
52
53
54
55
#include<iostream>
#include<list>
int main()
{
//demonstrating the list
std::list<int> lt;
//inserting elements in the list
for(int i=0;i<10;i++)
{
lt.push_back(i);
}
//printing the contents of the list
std::list<int>::iterator p = lt.begin();
std::cout<<"List : ";
while(p!=lt.end())
{
std::cout<<*p<<" ";
p++;
}
std::cout<<std::endl;
//changing the contents of the list
p = lt.begin();
while(p!=lt.end())
{
*p = *p + 100;
p++;
}
std::cout<<"Modified List : ";
p = lt.begin();
while(p!=lt.end())
{
std::cout<<*p<<" ";
p++;
}
std::cout<<std::endl;
//deleting the first and the last element of the list
lt.pop_back();
lt.pop_front();
std::cout<<"Modified List : ";
p = lt.begin();
while(p!=lt.end())
{
std::cout<<*p<<" ";
p++;
}
std::cout<<std::endl;
return 0;
}