答案代码很简单,其实写这篇题解没有多大思想上的提升,而是我们的武器库增加了一个库函数,而这个库函数就是next_permutation
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
string s;
while (cin>>s) {
sort(s.begin(), s.end());
cout<< s << endl;
for (s.begin(); next_permutation(s.begin(), s.end());) {
cout<< s << endl;
}
cout << endl;
}
return 0;
}

京公网安备 11010502036488号