Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. using namespace std;
  4. int main()
  5. {
  6.     queue <int> s;
  7.  
  8.     char c;
  9.     int y;
  10.     while (true){
  11.         cin>>c>>y;
  12.  
  13.         if (c=='a'){
  14.             s.push(y);
  15.         }
  16.  
  17.         if (c=='d'){
  18.             if(!s.empty()) {
  19.                 cout<<s.front()<<endl;
  20.                  s.pop();
  21.             }
  22.             else{
  23.                     cout<<"the stack is empty"<<endl;
  24.                     break;
  25.             }
  26.         }
  27.  
  28.         if ((c!='a') && (c!='d')) {
  29.             while(!s.empty()){
  30.                 cout<<s.front()<<endl;
  31.                 s.pop();
  32.             }
  33.             break;
  34.         }
  35.     }
  36.  
  37.     return 0;
  38.  
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement