DasShelmer

7.2.19

Nov 12th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string in, out;
  8.     int lenght, i, j;
  9.  
  10.     setlocale(LC_ALL, "Russian");
  11.  
  12.     cout << "Введите строку: ";
  13.     getline(cin, in);
  14.     lenght = in.length();
  15.     out = in;
  16.  
  17.     for (i = 1, j = 0; i < lenght; i += 2, j++)
  18.         out[j] = in[i];
  19.  
  20.     for (i = 0, j = lenght-1; i < lenght; i += 2, j--)
  21.         out[j] = in[i];
  22.  
  23.     cout << out;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment