#include<limits> #include<string> #include<iostream> using namespace std; int returnPermutations(string input, string output[]) { if(input.length() == 0) { output[0] = ""; return 1; } string smallOutput[10000]; int smallSize = returnPermutations(input.substr(1), smallOutput); int k = 0; for(int i = 0; i < smallSize; i++) { for(int j = 0; j <=smallOutput[i].length(); j++) { output[k++] = smallOutput[i].substr(0,j) + input[0] + smallOutput[i].substr(j); } } return k; } string getStr(string s) { int l; l=s.length(); string r=""; for(int i=0;i<l;i++) { if(s[i]!=' ') r=r+s[i]; } return r; } int main() { string sol[10000]; string s; getline(cin,s); sol[10000]=getStr(s); string output[10000]; int count = returnPermutations(sol,output); for(int i = 0; i < count && i <10000; i++){ cout << output[i] << endl; } return 0; }
sol[10000] = getStr(s)
sol
int count = returnPermutations(sol, output)
sol[0]
string* input
string input
returnPermutations
input.substr(1)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)