-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.cpp
More file actions
32 lines (24 loc) · 670 Bytes
/
Copy pathlist.cpp
File metadata and controls
32 lines (24 loc) · 670 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
// Create a List
list<int> l = {10, 20, 30};
// Iterator pointing to first element
auto itr = l.begin();
// Advance the Iterator to point to
// second element
itr++;
// Insert 15 at second position keeping the
// interator at second position only
itr = l.insert(itr, 15);
// Insert 7 two times at position 2
l.insert(itr, 3, 7);
// Print elemnet at front and rear end
cout<<l.front()<<" "<<l.back();
// Print size of the list
cout<<" "<<l.size()<<endl;
for(auto i:l)
cout<<i<< " ";
return 0;
}