Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. //HSGS 2017-2020 - 10A1[A0] - #16
  2. #include <iostream>
  3. #include <ios>
  4. #include <regex>
  5. #include <array>
  6. #include <string>
  7. #include <cstdio>
  8. #include <algorithm>
  9. #include <iterator>
  10. #include <cmath>
  11. #include <iomanip>
  12. #include <cstring>
  13. #include <string>
  14. #include <cstdlib>
  15. #include <fstream>
  16.  
  17. using namespace std;
  18.  
  19. string processSet(string t);
  20.  
  21. int main()
  22. {
  23.     freopen("bclgold.inp","r",stdin);
  24.     freopen("bclgold.out","w",stdout);
  25.     unsigned long long int querycount;
  26.     cin >> querycount; string queries = "";
  27.     for (unsigned long long int i = 1 ; i <= querycount ; i++)
  28.     {
  29.         fflush(stdin);
  30.         //char t = getchar();
  31.         char t; cin >> t;
  32.         queries = queries + t;
  33.     };
  34.     cout << processSet(queries);
  35. }
  36.  
  37.  
  38. string processSet(string t)
  39. {
  40.     string str = t, answer = "";
  41.     transform(str.begin(),str.end(),str.begin(),::toupper);
  42.     while (!str.empty())
  43.     {
  44.         char frontElement = *(str.begin()), backElement = str[str.length() - 1];
  45.         if (frontElement < backElement)
  46.         {
  47.             answer = answer + frontElement;
  48.             str.erase(0,1);
  49.         }
  50.         else
  51.         {
  52.             answer = answer + backElement;
  53.             str.pop_back();
  54.         }
  55.     };
  56.     return answer;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement