Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- list<char> l;
- bool is=false;
- char idx;
- string s;
- cin>>s;
- for(int i=0; i<s.size(); i++)
- {
- if(s[i]!='['&&s[i]!=']'&&is==false)
- {
- l.push_back(s[i]);
- }
- else if(s[i]!='['&&s[i]!=']'&&is==true)
- {
- l.insert(idx,s[i]);
- }
- else if(s[i]=='[')
- {
- is=true;
- idx=l.begin();
- }
- else if(s[i]==']')
- {
- is=false;
- }
- }
- for (auto it : l)
- {
- cout<<it;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement