// Permutation.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
using namespace std;
void OutCh(char ch[])
{
int len=sizeof(ch)/sizeof(char);
for(int i=0;i<len;i++)
{
cout<<ch[i]<<" ";
}
cout<<endl;
}
void swap(char ch[],int m,int n)
{
char tmp=ch[m];
ch[m]=ch[n];
ch[n]=tmp;
}
void Permutation(char ch[],int low,int high)
{
if(low<high)
{
for(int i=low;i<=high;i++)
{
swap(ch,i,low);
Permutation(ch,low+1,high);
swap(ch,i,low);
}
}
else
OutCh(ch);
}
int _tmain(int argc, _TCHAR* argv[])
{
char Test[]={'a','b','c','d'};
Permutation(Test,0,3);
cin.get();
return 0;
}