#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <algorithm> #include <stdlib.h> #include <vector> #include <map> #include <queue> #include <string> #include <iostream> #include <ctype.h> #include <string.h> #include <set> #include <stack> #include<functional> using namespace std; #define Size 27 #define maxn 1<<30 int mark[Size]; int b[Size]; char a[Size]; set<char> s; vector<char> v; int len; void dfs(int pos){ if (pos > len){ vector<char>::iterator iter = v.begin(); for (; iter < v.end(); iter++) cout << *iter; cout << endl; return; } for (int i = 0; i < 26; i++){ if (b[i] && mark[i] == 0) { char c = i+ ‘a‘; v.push_back(c); mark[i] = 1; dfs(pos + 1); mark[i] = 0; v.pop_back(); } } } int main(){ cin >> a; len = strlen(a); for (int i = 0; i < len; i++) b[a[i] - ‘a‘]++; dfs(1); system("pause"); return 0; }