- #include<bits/stdc++.h>
- using namespace std;
- queue<int> q;
- stack<int> s;
- int main()
- {
- q.push(1);
- q.push(2);
- q.push(3);
- q.push(4);
- q.push(5);
- s.push(1);
- s.push(2);
- s.push(3);
- s.push(4);
- s.push(5);
- s.pop();
- s.pop();
- s.pop();
- s.push(5);
- s.push(4);
- s.push(3);
- while(!q.empty())
- {
- cout<<q.front()<<" ";
- q.pop();
- }
- cout<<endl<<"-------"<<endl;
- while(!s.empty())
- {
- cout<<s.top()<<" ";
- s.pop();
- }
- return 0;
- }
複製代碼 |