there is a problem with the set statement
#include
#include
#include
using namespace std;
void perm(char *in,int i , set &s)
{
if (in[i]==’\0’)
{//cout<<in<<endl;
string t(in);
s.insert(t);
}
for(int j=i;in[j]!='\0';j++ )
{
swap(in[i],in[j]);
perm(in,i+1,s);
swap(in[i],in[j]);// this is backtracking
}
}
int main()
{
char in[100];
cin>>in;
set s;
perm(in,0,s);
for(auto str:s)
cout<< str<<", ";
return 0;
}