private static void perm(int[] list, int i, int n)
{
int j;
if (i == n)
{
for (int m = 0; m < list.GetUpperBound(0) + 1; m++)
{
Console.Write(list[m]);
}
Console.WriteLine(" ");
}
else
{
for (j = i; j <= n; j++)
{
SWAP(ref list[i], ref list[j]);
perm(list, i + 1, n);
SWAP(ref list[i], ref list[j]);//数组一定要复原!!!!!
}
}
}
private static void SWAP(ref int a, ref int b)
{
int c = a;
a = b;
b = c;
}