Bob103

римская 2 строки

Dec 22nd, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string str, result;
  9. cout<<"Enter string"<<endl;
  10. getline(cin,str);
  11. const int len = str.length();
  12. for (int i = 1; i<len; i += 2)
  13. {
  14. result += str[i];
  15. }
  16. for (int i = len % 2 ? len - 1 : len - 2; i >= 0; i -= 2)
  17. {
  18. result += str[i];
  19. }
  20. cout << result << endl;
  21. system("pause");
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment