Demonstrate resize() for deque : Deque « Data Structure « C++






Demonstrate resize() for deque

Demonstrate resize() for deque


#include <iostream>
#include <deque>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
  deque<double> dequeObject1, dequeObject2;
  double num;
  int i;

  for(;;) {
    cout << "Enter angles (0 to stop): ";
    cin >> num;
    if(num == 0.0) break;
    dequeObject1.push_back(num);
  }

  dequeObject2.resize(dequeObject1.size());

  for(i = 0; i <dequeObject2.size(); i++) {
    cout << "Angle and sine: ";
    cout << dequeObject1[i] << " " << dequeObject2[i];
    cout << endl;
  }
  cout << endl;
   
  return 0;
}

           
       








Related examples in the same category

1.One way to reverse-copy a deque.One way to reverse-copy a deque.
2.Use reverse iterators.Use reverse iterators.
3.Reverse iterators and copy.Reverse iterators and copy.
4.Assigning deque objects.Assigning deque objects.
5.Demonstrate swap() for dequeDemonstrate swap() for deque
6.Iterator values may change.Iterator values may change.
7.Demonstrate raw storage iteratorsDemonstrate raw storage iterators
8.Demonstrate a deque.Demonstrate a deque.
9.Deque: push, pop, sort, find, begin, end, insertDeque: push, pop, sort, find, begin, end, insert