Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string str, result;
- cout<<"Enter string"<<endl;
- getline(cin,str);
- const int len = str.length();
- for (int i = 1; i<len; i += 2)
- {
- result += str[i];
- }
- for (int i = len % 2 ? len - 1 : len - 2; i >= 0; i -= 2)
- {
- result += str[i];
- }
- cout << result << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment