Advertisement
Guest User

Bar Apis

a guest
Oct 15th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. string s,t;
  5. int n,sp[1000],sg[1000],x,rp=0,rg=0;
  6. int main()
  7. {
  8.     ios_base::sync_with_stdio(0);
  9.     cin.tie(0);
  10.     cout.tie(0);
  11.        cin>>n;
  12.        for(int i=0;i<n;i++)
  13.        {
  14.            cin>>s>>t;
  15.  
  16.            if(s=="dziekuje")
  17.            { cin>>x;
  18.                if(t=="plytki")
  19.                {
  20.                    sp[rp]=x;
  21.                    rp++;
  22.                }
  23.                else
  24.                {
  25.                    sg[rg]=x;
  26.                    rg++;
  27.                }
  28.                }
  29.                else
  30.                {
  31.                    if(t=="plytki")
  32.                    {       if(rp>0){
  33.                        cout<<sp[rp-1]<<endl;
  34.                        rp--;}
  35.  
  36.                    }
  37.                    else
  38.                    {        if(rg>0){
  39.                        cout<<sg[rg-1]<<endl;
  40.                        rg--;}
  41.  
  42.                    }
  43.                }
  44.  
  45.            }
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement