All pastes #630894 Raw Edit

Mine

public text v1 · immutable
#630894 ·published 2007-07-23 15:45 UTC
rendered paste body
#include<iostream.h>
#include<conio.h>
#include<string.h>

int N;
char *str="sandy";

static counter;

int a[10];
void permute(int n);
void main()
{
	clrscr();

	N = strlen(str);
	permute(0);
	cout<<"Total combinations = "<<counter;
		getch();
}

void permute(int n)
{

	if(n<N)
	{
		for(int i=0;i<N;i++)
		{
			a[n] = i;
			permute(n+1);
		}
	}
	else
	{
		int flag=1;
		for(int l=0;l<N;l++)
		{
			for(int m=l+1;m<N;m++)
			{
				if(a[l]==a[m])
				{
					flag=0;
					break;
				}
			}
				if(flag==0)
				{
					break;
				}

		}

		if(flag==1)
		{
		counter++;
		for(int k=0;k<N;k++)
		{
			cout<<str[a[k]];
		}
		cout<<endl;
		}
	}

}