Deque | Deque Program in C++
A deque, otherwise called a double-ended queue, is an arranged gathering of things like the queue. It has two finishes, a front, and a rear, and the things remain situated in the gatherDeque C++ program
#include<iostream>#include<deque>
#include<algorithm>
#include<iterator>
using namespace std;
int main()
{
deque<double> v1;
double x;
ostream_iterator<double> output(cout," ");
cout<<"Enter a number : ";
cin>>x;
v1.push_back(x);
cout<<"Enter a number : ";
cin>>x;
v1.push_front(x);
cout<<"Enter a number : ";
cin>>x;
v1.push_back(x);
for(int i=0;i<v1.size();i++)
cout<<v1[i]<<" ";
cout<<endl;
v1.pop_front();
copy(v1.begin(),v1.end(),output);
v1[1]=13.6;
cout<<endl;
copy(v1.begin(),v1.end(),output);
return 0;}
OUTPUT:
Enter a number : 5
Enter a number : 2
Enter a number : 14
2 5 14
5 14
5 13.6
tags : deque, deque in C++, deque C++.
Tags:
implementation of deque