我用 C++和 C#分别计算从 1 皇后到 12 皇后,都有哪些解,结果 C#用了 3.1-3.2 秒,用 C++写的竟然用到了了 17.6-17.9 秒,我是用 std:vector 来收集结果的,是这个产生的性能问题吗?
C++版本代码: https://github.com/plantain-00/c-demo/blob/master/EightQueens/EightQueens/main.cpp
C#版本代码: https://github.com/plantain-00/csharp-demo/blob/master/SevenQueens/Program.cs
当然了,是在同一台机器上跑的。
C++版本代码: https://github.com/plantain-00/c-demo/blob/master/EightQueens/EightQueens/main.cpp
C#版本代码: https://github.com/plantain-00/csharp-demo/blob/master/SevenQueens/Program.cs
当然了,是在同一台机器上跑的。