Naxocist

Keyboard

Mar 30th, 2022
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define endll '\n'
  3. using namespace std;
  4.  
  5.  
  6. int main() {
  7.  
  8.     list<char> l;
  9.     string s; cin >> s;
  10.  
  11.     bool back = true;
  12.     list<char>::iterator it = l.end();
  13.  
  14.     for(char c : s){
  15.         if(c == '[') it = l.begin();
  16.  
  17.         else if(c == ']') it = l.end();
  18.  
  19.         else l.insert(it, c);
  20.  
  21.     }
  22.  
  23.     for(auto it : l) cout << it;
  24.  
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment