标签:
递归全排列(C#):
static int[] xx=new int[4];
static void Main(string[] args)
{
printP(4, xx, 0);
}
static void printP(int n,int [] A,int cur)
{
int i, j;
if (cur == n)
{
for (i = 0; i < n; i++)
Console.Write(A[i]);
Console.WriteLine();
}
else
for (i = 1; i <= n; i++)
{
int ok = 1;
for (j = 0; j < cur; j++)
if (A[j] == i) ok = 0;
if (ok == 1) { A[cur] = i; printP(n, A, cur + 1); }
}
}
标签:
原文地址:http://www.cnblogs.com/zhubenxi/p/5146278.html