Chinaunix首页 | 论坛 | 博客
  • 博客访问: 588443
  • 博文数量: 201
  • 博客积分: 3076
  • 博客等级: 中校
  • 技术积分: 2333
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-02 19:44
文章分类

全部博文(201)

文章存档

2010年(118)

2009年(83)

我的朋友

分类: C/C++

2009-12-14 11:55:23

#include
#include
int count = 0;
void Permutation(char a[], int start, int end)
{   
   int i,j;
   char temp;
   if(start == end)
   {
      count++;
      for(i = 0; i <= end; i++)
      
    printf(" %c ",a[i]);
    printf("\n");
   }
   else 
   {  
       for(i = start; i <= end; i++)
       {
           for(j=start;j                       if(a[j]==a[i]) goto next;
         
               temp=a[start]; a[start]=a[i]; a[i]=temp;
               Permutation(a, start+1, end);
               temp=a[start]; a[start]=a[i]; a[i]=temp;
               next:;
       }
  }
}

int main()
{
   char A[] = "accc";
   Permutation(A,0,3);
   printf("%d\n", count);
   return 0;
}

 
阅读(442) | 评论(0) | 转发(0) |
0

上一篇:特权级

下一篇:com 与 dll

给主人留下些什么吧!~~