#include
#include <bits/stdc++.h>
using namespace std;
set<char*> permutations;
void permute(char* ch, int i)
{
if(ch[i] == ‘\0’)
{
permutations.insert(ch);
return;
}
for(int j = i; ch[j]!='\0'; j++)
{
swap(ch[i],ch[j]);
permute(ch, i+1);
swap(ch[i],ch[j]);
}
}
int main() {
// your code goes here
char ch[9];
cin>>ch;
permute(ch,0);
set<char*> :: iterator itr;
for(itr = permutations.begin(); itr != permutations.end(); itr++)
{
cout<<*itr<<"\n";
}
return 0;
}
Why this is not working properly