Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. using namespace std;
  4. int main()
  5.  
  6.  
  7. {
  8.    
  9.     queue <int> podr;
  10.     string s;
  11.     int n;
  12.     cin>> s;
  13.     while (s!="exit")
  14.     {
  15.         if (s=="push")
  16.         {
  17.             cin>>n;
  18.             podr.push(n);
  19.             cout<<"ok"<< endl;
  20.         }
  21.         if (s=="pop")
  22.         {
  23.              if (!podr.empty()) {
  24.             cout<<podr.front()<<endl;
  25.             podr.pop();
  26.              }
  27.              else cout<<"error"<<endl;
  28.         }
  29.         if (s=="front")
  30.         {
  31.            
  32.             if (!podr.empty()) {
  33.            
  34.               cout<<podr.front()<<endl;
  35.              
  36.             }
  37.             else
  38.             cout<<"error"<<endl;
  39.         }
  40.         if (s=="size")
  41.         {
  42.             cout<<podr.size()<<endl;
  43.         }
  44.         if (s=="clear")
  45.         {
  46.         while(!podr.empty())
  47.         {
  48.             podr.pop();
  49.         }
  50.         cout<<"ok"<<endl;
  51.         }
  52.        
  53.        
  54.        
  55.        
  56.        
  57.        
  58.         cin>>s;
  59.     }
  60.    
  61.    
  62.    
  63.    
  64.    
  65.    
  66.    
  67.     cout<<"bye";
  68.    
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement