#include "stdafx.h"
void permutation(char * str, char * begin)
{
if(!str || !begin)
return;
if(*begin == '\0')
printf("%s\n",str);
else
{
for(char * cur = begin; *cur != '\0'; cur++)
{
char temp = *cur;
*cur = *begin;
*begin = temp;
permutation(str, begin+1);
temp = *cur;
*cur = *begin;
*begin = temp;
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
char str[] = "abc";
permutation(str,str);
return 0;
}
浙公网安备 33010602011771号