#include<iostream> #include<cstdio> #include<string> using namespace std; void Print(string pattern, string print) { int num = pattern.size(); if (!num)cout << print << endl; //当模式串长度为零时说明全部被取到打印串中了,打印出来 for (int i = 0; i < num; ++i) { string temp1 = pattern; temp1.erase(i, 1); //模式串中删一个序最小的新字母,并放入打印串 string temp2 = print; temp2.insert(temp2.end(), pattern[i]); //取一个新字母到打印串中 Print(temp1, temp2); } } int main() { string pattern; string print; while (getline(cin, pattern)) { print.clear(); Print(pattern, print); } return 0; }