//基本都是多组数据测试,所以不要写一组数据的代码格式!!!//全排列next_permutation()函数还真得用do{}while()循环格式来写;#include<iostream> #include<algorithm> #include<string> using namespace std; int main() { string str; while (getline(cin, str))//cin读字符串遇到空格就截止,用getline是考虑到字符串可能有空格 { reverse(str.begin(), str.end());//翻转函数是左闭右开,可见end是结尾的下一个位置 cout << str << endl; } return 0; }
时间: 2024-08-24 20:55:55