void permute(char *a, int i, int n)
{
int j;
if (i == n)
printf(%s\n, a);
for (j = i; j = n; j++)
{
if(a[i] != a[j])
{ swap(a[i], a[j]); //just check before swapping if
you are swapping different elements
//or
formatting changes .
void permute(char *a, int i, int n)
{
int j;
if (i == n)
printf(%s\n, a);
for (j = i; j = n; j++)
{
if(a[i] != a[j]) check before swapping if you are
swapping different elements or not, if not then don't.
{ swap(a[i], a[j]);
Hi Don,
Good one :) Nice to see different approaches for this problem.
-Thanks,
Bujji
On Fri, Jan 10, 2014 at 9:11 AM, Don dondod...@gmail.com wrote:
Sort the input string and remove duplicates, keeping a count of the number
of occurrences of each character.
They you can build
Sort the input string and remove duplicates, keeping a count of the number
of occurrences of each character.
They you can build the permutations easily.
For your example, you would start with
char *str = aba;
int len = strlen(str);
Which would be converted to
char *str ab;
int rep[N] =