deque stl

Solutions on MaxInterview for deque stl by the best coders in the world

showing results for - "deque stl"
Niclas
02 Feb 2020
1#include<iostream>
2#include<deque>
3#include<algorithm>
4using namespace std;
5int main()
6{
7    ios_base::sync_with_stdio(false);
8    cin.tie(NULL);
9    deque<int>d;
10    d.push_back(50);
11    d.push_back(75);
12    d.push_front(25);
13    d.push_front(10);
14    d.push_back(100);
15    for(deque<int>::iterator it=d.begin();it!=d.end();it++)
16    {
17        cout<<*it<<endl;
18    }
19    cout<<"-----------------------"<<endl;
20    d.pop_back();
21    d.pop_front();
22    for(deque<int>::iterator it=d.begin();it!=d.end();it++)
23    {
24        cout<<*it<<endl;
25    }
26    cout<<"-----------------------"<<endl;
27    auto it1=d.begin()+1;
28    d.insert(it1,5,30);
29    for(deque<int>::iterator it=d.begin();it!=d.end();it++)
30    {
31        cout<<*it<<endl;
32    }
33    cout<<"-----------------------"<<endl;
34    deque<int>d1{10,20,30,40,50};
35    d.insert(it1,d1.begin(),d1.end());
36    for(deque<int>::iterator it=d.begin();it!=d.end();it++)
37    {
38        cout<<*it<<endl;
39    }
40    cout<<"-----------------------"<<endl;
41return 0;
42}
43