fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. #include<string.h>
  4. #define OPTIMIZE ios_base::sync_with_stdio(false); cin.tie(NULL)
  5. using namespace std;
  6. int main()
  7. {
  8. OPTIMIZE;
  9. string s;
  10. string newstr;
  11. cin >> s;
  12. char c;
  13. stack<char> st;
  14. int i;
  15.  
  16. for (i = 0; i < s.size(); i++)
  17. {
  18. c = s[i];
  19. if (c == '<')
  20. {
  21. if (!st.empty())
  22. {
  23. st.pop();
  24. }
  25. }
  26. else
  27. {
  28. st.push(c);
  29. }
  30. }
  31.  
  32.  
  33. while (!st.empty())
  34. {
  35. newstr = st.top() +newstr;
  36. st.pop();
  37. }
  38.  
  39. cout << newstr <<"\n";
  40.  
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0.01s 5380KB
stdin
Standard input is empty
stdout