-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.cpp
52 lines (47 loc) · 810 Bytes
/
list.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
#include<iostream>
#include<list>
using namespace std;
int main()
{
list<int> l;
l.push_back(1);
l.push_front(2);
for(auto i:l)
{
cout<<i<<" ";
}
cout<<endl;
// l.erase(l.begin());
for(auto i:l)
{
cout<<i<<" ";
}
cout<<endl;
cout<<"Size of ---> "<<l.size()<<endl;
//list all assign same element;
list<int> j;
j.push_back(1);
j.push_back(2);
j.push_back(3);
j.push_back(4);
j.push_back(5);
for(auto i:j)
{
cout<<i<<" ";
}cout<<endl;
j.pop_back();
for(auto i:j)
{
cout<<i<<" ";
}cout<<endl;
j.pop_front();
for(auto i:j)
{
cout<<i<<" ";
}cout<<endl;
for(auto i=j.begin();i!=j.end();i++)
{
cout<<*i<<" ";
}
return 0;
}