2014-07-10 02:18:43
题意&思路:不说啥了。。
1 #include <cstdio> 2 #include <iostream> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 using namespace std; 7 8 int main(){ 9 char s[15]; 10 int n,len; 11 cin >> n; 12 while(n--){ 13 cin >> s; 14 len = strlen(s); 15 sort(s,s + len); 16 cout << s << endl; 17 while(next_permutation(s,s + len)) cout << s << endl; 18 cout << endl; 19 } 20 return 0; 21 }
本文介绍了一个简单的C++程序,用于生成输入字符串的所有可能排列。通过使用标准库函数`next_permutation`实现字符串的全排列输出,并对每种排列进行打印。此算法适用于面试准备和技术笔试等场景。
774

被折叠的 条评论
为什么被折叠?



