Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <queue>
- using namespace std;
- void print_queue(queue<int> q)
- {
- vector<int> v;
- while (!q.empty())
- {
- v.push_back(q.front());
- q.pop();
- }
- for(int i = v.size()-1;i>=0;i--)
- {
- cout<<v[i]<<" ";
- }
- cout << endl;
- }
- int main()
- {
- queue<int> q;
- q.push(100);
- q.push(0);
- print_queue(q);
- int a = 0;
- int b = 0;
- while(1)
- {
- a = q.front();
- q.pop();
- print_queue(q);
- if(a == 0) break;
- q.push(a);
- print_queue(q);
- q.push(a);
- print_queue(q);
- q.push(1);
- print_queue(q);
- int x = q.front();q.pop();
- int y = q.front();q.pop();
- q.push(x+y);
- print_queue(q);
- x = q.front();q.pop();
- y = q.front();q.pop();
- q.push(x-y);
- print_queue(q);
- b = q.front();q.pop();
- q.push(b);
- print_queue(q);
- cout<<"----------------------------------\n";
- }
- cout << q.front();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement