日期:2014-05-20 浏览次数:20674 次
void perm (int [] source, int [] result, int index) {
for (int i = 0; i < source.length; i ++) {
for (int j = 0; j < index; j++) {
if (source[i] == result[j])
continue;
break;
}
result[index] = source[i];
break;
}
if (index == source.length -1)
return;
perm(source, result, index+1);
}
int[] source = {1, 2, 3};
int[] result = new int[3];
perm(source, result, 0);
#include <stdio.h>
#include <string.h>
char string[]="123456789a";
int used[10]={0};
char output[10];
int length;
void Fun(int d)
{
int i;
for(i=0;i<=length;i++)
{
if(!used[i])
{
used[i]=1;
output[d]=string[i];
if(d==length)
{
for(d=0;d<length;d++)
{
if(output[d]=='a')
printf("10 ");
else printf("%c ",output[d]);
}
if(output[length]=='a')
printf("10\n");
else
printf("%c\n",output[length]);
}
else
Fun(d+1);
used[i]=0;
}
}
}
int main()