fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. ios::sync_with_stdio(0);
  7. cin.tie(0),cout.tie(0);
  8. deque<char> left;
  9. deque<char> right;
  10. string s;
  11.  
  12. while (cin >> s)
  13. {
  14. bool r = true;
  15.  
  16. for (char c : s)
  17. {
  18. if (c == '[')
  19. {
  20. r = true;
  21. }
  22. else if (c == ']')
  23. {
  24. r = false;
  25. }
  26. else
  27. {
  28. if (r)
  29. {
  30. left.push_back(c);
  31. }
  32. else
  33. {
  34. right.push_back(c);
  35. }
  36. }
  37. }
  38.  
  39.  
  40. while (!left.empty())
  41. {
  42. cout << left.front();
  43. left.pop_front();
  44. }
  45. while (!right.empty())
  46. {
  47. cout << right.front();
  48. right.pop_front();
  49. }
  50. cout << endl;
  51. }
  52.  
  53. return 0;
  54. }
  55.  
Success #stdin #stdout 0s 5276KB
stdin
Name[My_]_Is_Mohemd
[[]][][]I_Am_FrOm_AssiUt
stdout
NameMy__Is_Mohemd
I_Am_FrOm_AssiUt