using System using System Collections Generic using System Linq using

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace ConsoleApplication {
public class Program {
private const int n = 3;
private static int[] b = new int[n];
private static bool[] u = new bool[n];
public static void Main(string[] args) {
generate(0);
}
private static void print() {
for (int j = 0; j < n; j++) {
Console.Write(b[j] + " ");
}
Console.WriteLine();
}
private static void generate(int i) {
if (i == n) {
print();
return;
}
for (int j = 0; j < n; j++) {
if (!u[j]) {
b[i] = j;
u[j] = true;
generate(i + 1);
u[j] = false;
}
}
}
}
}