方法调用:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
// Program.cs namespace EightQueens { class Program { static void Main( string [] args) { int queenCount = 12; List< int > queenList = new List< int >(); for ( int i = 0; i < queenCount; i++) { queenList.Add(0); } new EightQueens().putQueen(queenCount, queenList, 0); Console.ReadKey(); } } } |
当Queen的数量越多, 可以看到Python和C#的效率差距越大。18个Queen,运行几分钟之后: