Colin's Blog
Recent content on Colin's Blog
马上订阅 Colin's Blog RSS 更新: https://blog.oyyko.com/index.xml
N queens Problem
This article will provide a fast way to find a solution for the famous N queens problem.
Note: we only try to find one possibility of all positions of chesses, NOT (ALL posibilities).
For example, when N=8, there are 92 ways to put the chesses. However, our algorithm just focus on finding one of these 92 ways.
If you still feels not familar with the problem we will solve. Please Google 8 queens problem and look down.
N=4
When N=4, there are only two ways to put these chesses.
1010020001310004001010010210003000140100Our program, as I just said, will try to find one of the two ways.
So, Here we go~
Code
1#include <stdio.h> 2#include <stdlib.h> 3#include <time.h> 4#include <string.h> 5 6#define N 123456789 7 8 9//...剩余内容已隐藏
Colin's Blog
Recent content on Colin's Blog
马上订阅 Colin's Blog RSS 更新: https://blog.oyyko.com/index.xml
N queens Problem
This article will provide a fast way to find a solution for the famous N queens problem.
Note: we only try to find one possibility of all positions of chesses, NOT (ALL posibilities).
For example, when N=8, there are 92 ways to put the chesses. However, our algorithm just focus on finding one of these 92 ways.
If you still feels not familar with the problem we will solve. Please Google 8 queens problem and look down.
N=4
When N=4, there are only two ways to put these chesses.
1010020001310004001010010210003000140100Our program, as I just said, will try to find one of the two ways.
So, Here we go~
Code
1#include <stdio.h> 2#include <stdlib.h> 3#include <time.h> 4#include <string.h> 5 6#define N 123456789 7 8 9//...剩余内容已隐藏