(8×8inachessset,thereseight,eachaccountingforaQueensgridrequestwillnotbeanymutualbetweenQueensattackphenomenon,thatcannothavetwoQueensinthesameline,thesameroworthesamediagonal.Askedthetotalnumberofdifferentways.Thisalgorithmusesone-dimensionalarraytobeprocessed.Arraysubscriptisaidichessboardfirstout,a[i]valuethatsinthefirstplaceilistedbylocation.Suchas:a[1]=5,saidthefirstcasesinthechessboardofthefifthlineofaQueensrelease.) - IMDN开发者社群-imdn.cn">
登录
首页 » C/C++ » 8queen

8queen

于 2007-12-15 发布 文件大小:1KB
0 86
下载积分: 1 下载次数: 43

代码说明:

  在一个8×8国际象棋盘上,有8个皇后,每个皇后占一格;要求皇后间不会出现相互"攻击"的现象,即不能有两个皇后处在同一行、同一列或同一对角线上。问共有多少种不同的方法。 本算法采用一维数组来进行处理。数组的下标i表示棋盘上的第i列,a[i]的值表示皇后在第i列所放的位置。如:a[1]=5,表示在棋盘的第一例的第五行放一个皇后。(8 × 8 in a chess set, there s eight, each accounting for a Queen s grid request will not be any mutual between Queen s attack phenomenon, that can not have two Queen s in the same line, the same row or the same diagonal. Asked the total number of different ways. This algorithm uses one-dimensional array to be processed. Array subscript i said i chessboard first out, a [i] value that s in the first place i listed by location. Such as: a [1] = 5, said the first cases in the chessboard of the fifth line of a Queen s release.)

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 696524资源总数
  • 103930会员总数
  • 47今日下载