PROBLEM:-
Print Permutations - String
Send Feedback
abc
abc
acb
bac
bca
cab
cba
SOLUTION:-
#include <iostream>
#include <string>
using namespace std;
#include <iostream>
#include <string>
using namespace std;
void P(string input,string output)
{
if(input.empty())
{
cout<<output<<endl;
return;
}
for(int i=0;i<input.size();i++)
{
P(input.substr(0,i)+input.substr(i+1),input.substr(i,1)+output);
}
return;
}
void printPermutations(string input){
P(input,"");
return;
}
int main(){
string input;
cin >> input;
printPermutations(input);
return 0;
}
This is dummy text. It is not meant to be read. Accordingly, it is difficult to figure out when to end it. But then, this is dummy text. It is not meant to be read. Period.
If you have any doubts then please let me know... ConversionConversion EmoticonEmoticon