quantum

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

#include<iostream>
using namespace std;
const int list_size=4;
void perm(char list[],int i,int n);
int main()
{
char list[list_size]={'a','b','c','d'};
perm(list,0,list_size-1);
return 0;
}
void perm(char list[],int i,int n)
{
if(i==n){
for(int j=0;j<=n;j++)
cout<<list[j];
cout<<""<<endl;
}
else{
for(int j=i;j<=n;j++){
swap(list[i],list[j]);
perm(list,i+1,n);
swap(list[i],list[j]);
}
}
}

 

posted on 2012-02-28 16:47  quantum  阅读(161)  评论(0)    收藏  举报