#include <iostream>
#include <cstring>
using namespace std;
void swap (char *str, int i, int j)
{
char tmp = str[i];
str[i] = str[j];
str[j] = tmp;
}
void fullarrange (char *str, int beg, int nlen)
{
static int cnt = 0;
if ( beg < nlen-1)
{
for (int i=beg; i<nlen; i++)
{
swap(str, beg, i);
fullarrange(str, beg+1, nlen);
swap(str, beg, i);
}
}
else
{
cout<<++cnt<<": "<<str<<endl;
}
}
int main ()
{
char str[16]="abcde";
int nlen = strlen(str);
fullarrange(str, 0, nlen);
return 0;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)