UVA





思路:生成全排列,用next_permutation。注意生成之前先对那个字符数组排序。


AC代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

char str[20];

int main() {
	int n;
	cin >> n;
	while(n--) {
		scanf("%s", str);
		int len = strlen(str);
		sort(str, str + len);
		do
		{
			printf("%s
", str);
		}while(next_permutation(str, str + len));
		printf("
");
	}
	return 0;
} 












原文地址:https://www.cnblogs.com/zfyouxi/p/5207680.html