#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s; getline(cin, s); reverse(s.begin(), s.end()); cout << s; } // 64 位输出请用 printf("%lld")
- reverse()适用于静态数组、动态数组、字符串、链表、双端队列等多种标准库容器的翻转,尤其常用于动态数组和字符串的翻转。