@GatorGirl/

COP3530-Discussion2

C++11

No description

fork
loading
Files
  • main.cpp
main.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
//impliment a queue with 2 stacks
#include <iostream>
#include <stack>
using namespace std;

int main() 
{
  cout << "Start with Stack:" << endl;
  stack<int> a;
  stack<int> b;
  a.push(1);
  cout << 1 << endl;
  a.push(2);
  cout << 2 << endl;
  a.push(3);
  cout << 3 << endl;
  a.push(4);
  cout << 4 << endl;
  a.push(5);
  cout << 5 << " ~ top" << endl;

  cout << endl << "End with Queue" << endl;
  while (!a.empty())
  {
    b.push(a.top());
    a.pop();
  }

  cout << "top" << endl;
  while (!b.empty())
  {
    cout << b.top() << endl;
    b.pop();
  }
  return 0;
}