Advertisement
ekzolot

Untitled

Nov 27th, 2021
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <deque>
  3. using namespace std;
  4. int main(){
  5.     ios::sync_with_stdio(0);
  6.     cin.tie(0);
  7.     cout.tie(0);
  8.     int n;
  9.     cin>>n;
  10.     deque <int> a;
  11.     int k=0;
  12.     for (int i=0; i<n; i++){
  13.         char y;
  14.         cin>>y;
  15.         if (y == '+'){
  16.             int x;
  17.             cin>>x;
  18.             a.push_back(x);
  19.             k+=1;
  20.         }
  21.         if (y == '-'){
  22.             cout<<a.front()<<"\n";
  23.             a.pop_front();
  24.             k-=1;
  25.         }
  26.         if (y == '*'){
  27.             int m;
  28.             m=(k+1)/2;
  29.             a.resize(k+1);
  30.             for (int i=k-1; i>=m; i--){
  31.                 a[i+1]=a[i];
  32.             }
  33.             int x;
  34.             cin>>x;
  35.             a[m]=x;
  36.             k+=1;
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement