PhoenixZq
分享是一门艺术~~
#include <iostream>
using namespace std;

void Permutation(int* arr,int len,int length)
{
if(!arr && length<1)
return;
if(len == length)
{
for(int i=0;i<length;++i)
cout << arr[i];
cout << endl;
}
else
{
for(int j =len;j<length;++j)
{
int tmp = arr[j];
arr[j] = arr[len];
arr[len] = tmp;

Permutation(arr,len+1,length);

tmp = arr[j];
arr[j] = arr[len];
arr[len] = tmp;
}
}
}


int main()
{
int arr[] = {1,2,3};
Permutation(arr,0,3);

return 0;
}
posted on 2011-10-12 20:37  PhoenixZq  阅读(257)  评论(0编辑  收藏  举报