返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. queue<int> q;
  4. stack<int> s;
  5. int main()
  6. {
  7.     q.push(1);
  8.     q.push(2);
  9.     q.push(3);
  10.     q.push(4);
  11.     q.push(5);
  12.     q.push(0);

  13.     while(!q.empty())
  14.     {
  15.         cout<<q.front()<<" ";
  16.         q.pop();
  17.     }

  18.     cout<<endl<<"====================="<<endl;


  19.     s.push(1);
  20.     s.push(3);
  21.     s.push(5);
  22.     s.push(7);
  23.     s.push(9);
  24.     s.pop();
  25.     s.pop();
  26.     s.pop();
  27.     s.pop();
  28.     s.push(2);
  29.     s.push(4);

  30.     while(!s.empty())
  31.     {
  32.         cout<<s.top()<<" ";
  33.         s.pop();
  34.     }
  35.     return 0;
  36. }
複製代碼

TOP

返回列表