给,已经编译运行确认:
#include<stdio.h>
#include<string.h>
char a[20];
int lenth;
long count=0;
void main()
{void move(int,int);
int i,j=0;
printf("input:");gets(a);
lenth=strlen(a);
for(i=0;i<lenth;i++)
move(j,i);//move a[i] to the front of a[j];
printf("\ntotal=%d\n",count);
}
void move(int here,int which)//move a[which] to the front of a[here];
{char b[20];
char temp;
int m,n;
if(here<lenth-1)
{if(here!=which)
{for(m=0;m<lenth;m++)
b[m]=a[m];
temp=a[which];
for(m=which;m>here;m--)
a[m]=a[m-1];
a[m]=temp;
}
for(n=here+1;n<lenth;n++)
move(here+1,n);
if(here!=which)
for(m=0;m<lenth;m++)
a[m]=b[m];
}
else
{printf("%-10s",a);
count++;}
}
温馨提示:内容为网友见解,仅供参考