Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
class Derangements
|
||||
{
|
||||
static int n = 4;
|
||||
static int [] buf = new int [n];
|
||||
static bool [] used = new bool [n];
|
||||
|
||||
static void Main()
|
||||
{
|
||||
for (int i = 0; i < n; i++) used [i] = false;
|
||||
rec(0);
|
||||
}
|
||||
|
||||
static void rec(int ind)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (!used [i] && i != ind)
|
||||
{
|
||||
used [i] = true;
|
||||
buf [ind] = i;
|
||||
if (ind + 1 < n) rec(ind + 1);
|
||||
else Console.WriteLine(string.Join(",", buf));
|
||||
used [i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue