123456789
#include <iostream> #include <string> #include <algorithm> int main() { std::string s = "hello"; std::iter_swap(s.begin(), s.rbegin()); std::cout << s << '\n'; }