Advertisement
OIQ

Untitled

OIQ
Oct 3rd, 2021
796
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. void fastIO() {
  5.     std::ios_base::sync_with_stdio(false);
  6.     std::cin.tie(0);
  7.     std::cout.tie(0);
  8. }
  9.  
  10. int main() {
  11.     fastIO();
  12.     std::string str;
  13.     std::cin >> str;
  14.  
  15.     std::string encodeStr(str.size() - 1, ' ');
  16.  
  17.     for (int i = 0; i < str.size() - 1; i++) {
  18.         if (!(i % 2)) {
  19.             encodeStr[i / 2] = str[i];
  20.         } else {
  21.             encodeStr[encodeStr.size() - i / 2 - 1] = str[i];
  22.         }
  23.     }
  24.  
  25.     std::cout << encodeStr;
  26.  
  27.     return 0;
  28. }
  29.  
Advertisement
RAW Paste Data Copied
Advertisement