In the algorithm world, 8 queen is a very classic old problem, using the backtrack (recursive) is a standard answer for such problems, similar to the problem of the family, etc.
Share my source code: http://d2.yousendit.com/d/e7fa5590738888f7d57cc5deda10cba5/8queens.zip? Because of the server reasons, this file can only save 7 days.