static void Main(string[] args)
{
Console.WriteLine("请输入你想全排的数:");
int i = int.Parse(Console.ReadLine());
Program p = new Program();
p.book = new int[i];
p.hz = new int[i];
p.dsf(0);
Console.Read();
}
int[] book = null;
int[] hz = null;
private void dsf(int step)
{
if (step == hz.Length)
{
foreach (var item in hz)
{
Console.Write(item + 1);
}
Console.WriteLine();
return;
}
for (int i = 0; i < book.Length; i++)
{
if (book[i] == 0)
{
hz[step] = i;
book[i] = 1;
dsf(step + 1);
book[i] = 0;
}
}
}
Hold on, everything is possible.