Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- void ReverseString(std::string&);
- int main()
- {
- std::string s;
- std::cin >> s;
- ReverseString(s);
- std::cout << s << std::endl;
- return 0;
- }
- void ReverseString(std::string& s)
- {
- for (int i = 0; i < s.length() / 2; ++i)
- {
- char ch = s[i];
- s[i] = s[s.length() - i - 1];
- s[s.length() - i - 1] = ch;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment