-
Notifications
You must be signed in to change notification settings - Fork 1
/
1451.cpp
38 lines (35 loc) · 784 Bytes
/
1451.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
list<string>str;
while (cin>>s) {
string tmp="";
int len = s.size();
for (int i = len - 1; i >= 0; --i){
if (s[i] == '[')
for (int j = i + 1; s[j] != ']' && s[j] != '[' && j < len; ++j)
tmp+=s[j];
}
str.push_front(tmp);
tmp="";
for (int i = 0; s[i] != '[' && s[i] != ']' && i < len; ++i){
tmp+=s[i];
}
str.push_back(tmp);
tmp="";
for (int i = 0; i < len; ++i){
if (s[i] == ']')
for (i = i + 1; s[i] != '[' && i < len; ++i)
if (s[i] != ']')
tmp+=s[i];
}
str.push_back(tmp);
for(auto it:str)
cout<<it;
str.clear();
cout<<endl;
}
return 0;
}