我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

本页主题: 求助---一个N-皇后求解问题 显示签名 | 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

战无敌平琼宇



性别: 保密 状态: 该用户目前不在线
等级: 鹤立鸡群
家族: 低调一族
发贴: 1135
威望: 0
浮云: 1126
在线等级:
注册时间: 2006-08-17
最后登陆: 2007-06-11

5come5帮你背单词 [ nor /no:/ conj. 也不 ]


求助---一个N-皇后求解问题

inlist(1,L,[1|L]).
inlist(X,L1,L2):-
X>1,
Y is X-1,
inlist(Y,[X|L1],L2).

queens(N,Solutions):-
inlist(N,[],L),
solve([],Solutons,L,L).

solve(Input,Output,[Row|R],Columns):-
choose(Col,Columns,C),
Up is Row+Col,
Down is Row-Col,
safe(Up,Down,Input),
solve([square(Col,Up,Down)|Input],Output,R,C).
solve(L,L,[],[]).

choose(X,[X|Y],Y).
choose(X,[H|T1],[H|T2]):-
choose(X,T1,T2).

safe(U1,D1,[square(_,U,D)|Rest]):-
U1\=U,D1\=D,
safe(U1,D1,Rest).
safe(_,_,[]).

n_queens:-
write("The size of the chessboar N="),
read(N),
queens(N,Solutions),
print_board(N,Solutions),
fail.

print_board(N,[square(X,_,_)|L]):-
nl,
Y is X-1,
write_dots(Y),
write(Q),
W is N-X,
write_dots(W),
print_board(N,L).

write_dots(X):-
X>0,
write("."),
Y is X-1,
write_dots(Y).

write_dots(0).


n_queens.
The size of the chessboar N=2
THE$126
Syntax error in parser
No solutions
Reconsulted from: C:\Documents and Settings\Administrator\My Documents\Visual Prolog 7.0 Examples\pie\EXE\FILE6.PRO
n_queens.
The size of the chessboar N=Trace is On
3
Trace: >> CALL:   queens(3,SOLUTIONS$127)
Trace: >> CALL:   inlist(3,[],L$128)
Trace: >> CALL:   3 > 1
Trace: >> RETURN: 3 > 1
Trace: >> CALL:   Y$129 is 3 - 1
Trace: >> RETURN: 2 is 3 - 1
Trace: >> CALL:   inlist(2,[3|[]],L$128)
Trace: >> CALL:   2 > 1
Trace: >> RETURN: 2 > 1
Trace: >> CALL:   Y$130 is 2 - 1
Trace: >> RETURN: 1 is 2 - 1
Trace: >> CALL:   inlist(1,[2|[3|[]]],L$128)
Trace: >> RETURN: inlist(1,[2|[3|[]]],[1|[2|[3|[]]]])
Trace: >> RETURN: inlist(2,[3|[]],[1|[2|[3|[]]]])
Trace: >> RETURN: inlist(3,[],[1|[2|[3|[]]]])
Trace: >> CALL:   solve([],SOLUTONS$131,[1|[2|[3|[]]]],[1|[2|[3|[]]]])
Trace: >> CALL:   choose(COL$132,[1|[2|[3|[]]]],C$133)
Trace: >> RETURN: choose(1,[1|[2|[3|[]]]],[2|[3|[]]])
Trace: >> CALL:   UP$134 is 1 + 1
Trace: >> RETURN: 2 is 1 + 1
Trace: >> CALL:   DOWN$135 is 1 - 1
Trace: >> RETURN: 0 is 1 - 1
Trace: >> CALL:   safe(2,0,[])
Trace: >> RETURN: safe(2,0,[])
Trace: >> CALL:   solve([square(1,2,0)|[]],SOLUTONS$131,[2|[3|[]]],[2|[3|[]]])
Trace: >> CALL:   choose(COL$136,[2|[3|[]]],C$137)
Trace: >> RETURN: choose(2,[2|[3|[]]],[3|[]])
Trace: >> CALL:   UP$138 is 2 + 2
Trace: >> RETURN: 4 is 2 + 2
Trace: >> CALL:   DOWN$139 is 2 - 2
Trace: >> RETURN: 0 is 2 - 2
Trace: >> CALL:   safe(4,0,[square(1,2,0)|[]])
Trace: >> CALL:   4 \= 2
Trace: >> RETURN: 4 \= 2
Trace: >> CALL:   0 \= 0
Trace: >> FAIL:   0 \= 0
Trace: >> REDO:   4 \= 2
Trace: >> FAIL:   4 \= 2
Trace: >> FAIL:   safe(4,0,[square(1,2,0)|[]])
Trace: >> REDO:   0 is 2 - 2
Trace: >> FAIL:   DOWN$139 is 2 - 2
Trace: >> REDO:   4 is 2 + 2
Trace: >> FAIL:   UP$138 is 2 + 2
Trace: >> REDO:   choose(2,[2|[3|[]]],[3|[]])
Trace: >> CALL:   choose(COL$136,[3|[]],T2$140)
Trace: >> RETURN: choose(3,[3|[]],[])
Trace: >> RETURN: choose(3,[2|[3|[]]],[2|[]])
Trace: >> CALL:   UP$138 is 2 + 3
Trace: >> RETURN: 5 is 2 + 3
Trace: >> CALL:   DOWN$139 is 2 - 3
Trace: >> RETURN: -1 is 2 - 3
Trace: >> CALL:   safe(5,-1,[square(1,2,0)|[]])
Trace: >> CALL:   5 \= 2
Trace: >> RETURN: 5 \= 2
Trace: >> CALL:   -1 \= 0
Trace: >> RETURN: -1 \= 0
Trace: >> CALL:   safe(5,-1,[])
Trace: >> RETURN: safe(5,-1,[])
Trace: >> RETURN: safe(5,-1,[square(1,2,0)|[]])
Trace: >> CALL:   solve([square(3,5,-1)|[square(1,2,0)|[]]],SOLUTONS$131,[3|[]],[2|[]])
Trace: >> CALL:   choose(COL$141,[2|[]],C$142)
Trace: >> RETURN: choose(2,[2|[]],[])
Trace: >> CALL:   UP$143 is 3 + 2
Trace: >> RETURN: 5 is 3 + 2
Trace: >> CALL:   DOWN$144 is 3 - 2
Trace: >> RETURN: 1 is 3 - 2
Trace: >> CALL:   safe(5,1,[square(3,5,-1)|[square(1,2,0)|[]]])
Trace: >> CALL:   5 \= 5
Trace: >> FAIL:   5 \= 5
Trace: >> FAIL:   safe(5,1,[square(3,5,-1)|[square(1,2,0)|[]]])
Trace: >> REDO:   1 is 3 - 2
Trace: >> FAIL:   DOWN$144 is 3 - 2
Trace: >> REDO:   5 is 3 + 2
Trace: >> FAIL:   UP$143 is 3 + 2
Trace: >> REDO:   choose(2,[2|[]],[])
Trace: >> CALL:   choose(COL$141,[],T2$145)
Trace: >> FAIL:   choose(COL$141,[],T2$145)
Trace: >> FAIL:   choose(COL$141,[2|[]],C$142)
Trace: >> FAIL:   solve([square(3,5,-1)|[square(1,2,0)|[]]],SOLUTONS$131,[3|[]],[2|[]])
Trace: >> REDO:   safe(5,-1,[square(1,2,0)|[]])
Trace: >> REDO:   safe(5,-1,[])
Trace: >> FAIL:   safe(5,-1,[])
Trace: >> REDO:   -1 \= 0
Trace: >> FAIL:   -1 \= 0
Trace: >> REDO:   5 \= 2
Trace: >> FAIL:   5 \= 2
Trace: >> FAIL:   safe(5,-1,[square(1,2,0)|[]])
Trace: >> REDO:   -1 is 2 - 3
Trace: >> FAIL:   DOWN$139 is 2 - 3
Trace: >> REDO:   5 is 2 + 3
Trace: >> FAIL:   UP$138 is 2 + 3
Trace: >> REDO:   choose(3,[2|[3|[]]],[2|[]])
Trace: >> REDO:   choose(3,[3|[]],[])
Trace: >> CALL:   choose(COL$136,[],T2$146)
Trace: >> FAIL:   choose(COL$136,[],T2$146)
Trace: >> FAIL:   choose(COL$136,[3|[]],T2$140)
Trace: >> FAIL:   choose(COL$136,[2|[3|[]]],C$137)
Trace: >> FAIL:   solve([square(1,2,0)|[]],SOLUTONS$131,[2|[3|[]]],[2|[3|[]]])
Trace: >> REDO:   safe(2,0,[])
Trace: >> FAIL:   safe(2,0,[])
Trace: >> REDO:   0 is 1 - 1
Trace: >> FAIL:   DOWN$135 is 1 - 1
Trace: >> REDO:   2 is 1 + 1
Trace: >> FAIL:   UP$134 is 1 + 1
Trace: >> REDO:   choose(1,[1|[2|[3|[]]]],[2|[3|[]]])
Trace: >> CALL:   choose(COL$132,[2|[3|[]]],T2$147)
Trace: >> RETURN: choose(2,[2|[3|[]]],[3|[]])
Trace: >> RETURN: choose(2,[1|[2|[3|[]]]],[1|[3|[]]])
Trace: >> CALL:   UP$134 is 1 + 2
Trace: >> RETURN: 3 is 1 + 2
Trace: >> CALL:   DOWN$135 is 1 - 2
Trace: >> RETURN: -1 is 1 - 2
Trace: >> CALL:   safe(3,-1,[])
Trace: >> RETURN: safe(3,-1,[])
Trace: >> CALL:   solve([square(2,3,-1)|[]],SOLUTONS$131,[2|[3|[]]],[1|[3|[]]])
Trace: >> CALL:   choose(COL$148,[1|[3|[]]],C$149)
Trace: >> RETURN: choose(1,[1|[3|[]]],[3|[]])
Trace: >> CALL:   UP$150 is 2 + 1
Trace: >> RETURN: 3 is 2 + 1
Trace: >> CALL:   DOWN$151 is 2 - 1
Trace: >> RETURN: 1 is 2 - 1
Trace: >> CALL:   safe(3,1,[square(2,3,-1)|[]])
Trace: >> CALL:   3 \= 3
Trace: >> FAIL:   3 \= 3
Trace: >> FAIL:   safe(3,1,[square(2,3,-1)|[]])
Trace: >> REDO:   1 is 2 - 1
Trace: >> FAIL:   DOWN$151 is 2 - 1
Trace: >> REDO:   3 is 2 + 1
Trace: >> FAIL:   UP$150 is 2 + 1
Trace: >> REDO:   choose(1,[1|[3|[]]],[3|[]])
Trace: >> CALL:   choose(COL$148,[3|[]],T2$152)
Trace: >> RETURN: choose(3,[3|[]],[])
Trace: >> RETURN: choose(3,[1|[3|[]]],[1|[]])
Trace: >> CALL:   UP$150 is 2 + 3
Trace: >> RETURN: 5 is 2 + 3
Trace: >> CALL:   DOWN$151 is 2 - 3
Trace: >> RETURN: -1 is 2 - 3
Trace: >> CALL:   safe(5,-1,[square(2,3,-1)|[]])
Trace: >> CALL:   5 \= 3
Trace: >> RETURN: 5 \= 3
Trace: >> CALL:   -1 \= -1
Trace: >> FAIL:   -1 \= -1
Trace: >> REDO:   5 \= 3
Trace: >> FAIL:   5 \= 3
Trace: >> FAIL:   safe(5,-1,[square(2,3,-1)|[]])
Trace: >> REDO:   -1 is 2 - 3
Trace: >> FAIL:   DOWN$151 is 2 - 3
Trace: >> REDO:   5 is 2 + 3
Trace: >> FAIL:   UP$150 is 2 + 3
Trace: >> REDO:   choose(3,[1|[3|[]]],[1|[]])
Trace: >> REDO:   choose(3,[3|[]],[])
Trace: >> CALL:   choose(COL$148,[],T2$153)
Trace: >> FAIL:   choose(COL$148,[],T2$153)
Trace: >> FAIL:   choose(COL$148,[3|[]],T2$152)
Trace: >> FAIL:   choose(COL$148,[1|[3|[]]],C$149)
Trace: >> FAIL:   solve([square(2,3,-1)|[]],SOLUTONS$131,[2|[3|[]]],[1|[3|[]]])
Trace: >> REDO:   safe(3,-1,[])
Trace: >> FAIL:   safe(3,-1,[])
Trace: >> REDO:   -1 is 1 - 2
Trace: >> FAIL:   DOWN$135 is 1 - 2
Trace: >> REDO:   3 is 1 + 2
Trace: >> FAIL:   UP$134 is 1 + 2
Trace: >> REDO:   choose(2,[1|[2|[3|[]]]],[1|[3|[]]])
Trace: >> REDO:   choose(2,[2|[3|[]]],[3|[]])
Trace: >> CALL:   choose(COL$132,[3|[]],T2$154)
Trace: >> RETURN: choose(3,[3|[]],[])
Trace: >> RETURN: choose(3,[2|[3|[]]],[2|[]])
Trace: >> RETURN: choose(3,[1|[2|[3|[]]]],[1|[2|[]]])
Trace: >> CALL:   UP$134 is 1 + 3
Trace: >> RETURN: 4 is 1 + 3
Trace: >> CALL:   DOWN$135 is 1 - 3
Trace: >> RETURN: -2 is 1 - 3
Trace: >> CALL:   safe(4,-2,[])
Trace: >> RETURN: safe(4,-2,[])
Trace: >> CALL:   solve([square(3,4,-2)|[]],SOLUTONS$131,[2|[3|[]]],[1|[2|[]]])
Trace: >> CALL:   choose(COL$155,[1|[2|[]]],C$156)
Trace: >> RETURN: choose(1,[1|[2|[]]],[2|[]])
Trace: >> CALL:   UP$157 is 2 + 1
Trace: >> RETURN: 3 is 2 + 1
Trace: >> CALL:   DOWN$158 is 2 - 1
Trace: >> RETURN: 1 is 2 - 1
Trace: >> CALL:   safe(3,1,[square(3,4,-2)|[]])
Trace: >> CALL:   3 \= 4
Trace: >> RETURN: 3 \= 4
Trace: >> CALL:   1 \= -2
Trace: >> RETURN: 1 \= -2
Trace: >> CALL:   safe(3,1,[])
Trace: >> RETURN: safe(3,1,[])
Trace: >> RETURN: safe(3,1,[square(3,4,-2)|[]])
Trace: >> CALL:   solve([square(1,3,1)|[square(3,4,-2)|[]]],SOLUTONS$131,[3|[]],[2|[]])
Trace: >> CALL:   choose(COL$159,[2|[]],C$160)
Trace: >> RETURN: choose(2,[2|[]],[])
Trace: >> CALL:   UP$161 is 3 + 2
Trace: >> RETURN: 5 is 3 + 2
Trace: >> CALL:   DOWN$162 is 3 - 2
Trace: >> RETURN: 1 is 3 - 2
Trace: >> CALL:   safe(5,1,[square(1,3,1)|[square(3,4,-2)|[]]])
Trace: >> CALL:   5 \= 3
Trace: >> RETURN: 5 \= 3
Trace: >> CALL:   1 \= 1
Trace: >> FAIL:   1 \= 1
Trace: >> REDO:   5 \= 3
Trace: >> FAIL:   5 \= 3
Trace: >> FAIL:   safe(5,1,[square(1,3,1)|[square(3,4,-2)|[]]])
Trace: >> REDO:   1 is 3 - 2
Trace: >> FAIL:   DOWN$162 is 3 - 2
Trace: >> REDO:   5 is 3 + 2
Trace: >> FAIL:   UP$161 is 3 + 2
Trace: >> REDO:   choose(2,[2|[]],[])
Trace: >> CALL:   choose(COL$159,[],T2$163)
Trace: >> FAIL:   choose(COL$159,[],T2$163)
Trace: >> FAIL:   choose(COL$159,[2|[]],C$160)
Trace: >> FAIL:   solve([square(1,3,1)|[square(3,4,-2)|[]]],SOLUTONS$131,[3|[]],[2|[]])
Trace: >> REDO:   safe(3,1,[square(3,4,-2)|[]])
Trace: >> REDO:   safe(3,1,[])
Trace: >> FAIL:   safe(3,1,[])
Trace: >> REDO:   1 \= -2
Trace: >> FAIL:   1 \= -2
Trace: >> REDO:   3 \= 4
Trace: >> FAIL:   3 \= 4
Trace: >> FAIL:   safe(3,1,[square(3,4,-2)|[]])
Trace: >> REDO:   1 is 2 - 1
Trace: >> FAIL:   DOWN$158 is 2 - 1
Trace: >> REDO:   3 is 2 + 1
Trace: >> FAIL:   UP$157 is 2 + 1
Trace: >> REDO:   choose(1,[1|[2|[]]],[2|[]])
Trace: >> CALL:   choose(COL$155,[2|[]],T2$164)
Trace: >> RETURN: choose(2,[2|[]],[])
Trace: >> RETURN: choose(2,[1|[2|[]]],[1|[]])
Trace: >> CALL:   UP$157 is 2 + 2
Trace: >> RETURN: 4 is 2 + 2
Trace: >> CALL:   DOWN$158 is 2 - 2
Trace: >> RETURN: 0 is 2 - 2
Trace: >> CALL:   safe(4,0,[square(3,4,-2)|[]])
Trace: >> CALL:   4 \= 4
Trace: >> FAIL:   4 \= 4
Trace: >> FAIL:   safe(4,0,[square(3,4,-2)|[]])
Trace: >> REDO:   0 is 2 - 2
Trace: >> FAIL:   DOWN$158 is 2 - 2
Trace: >> REDO:   4 is 2 + 2
Trace: >> FAIL:   UP$157 is 2 + 2
Trace: >> REDO:   choose(2,[1|[2|[]]],[1|[]])
Trace: >> REDO:   choose(2,[2|[]],[])
Trace: >> CALL:   choose(COL$155,[],T2$165)
Trace: >> FAIL:   choose(COL$155,[],T2$165)
Trace: >> FAIL:   choose(COL$155,[2|[]],T2$164)
Trace: >> FAIL:   choose(COL$155,[1|[2|[]]],C$156)
Trace: >> FAIL:   solve([square(3,4,-2)|[]],SOLUTONS$131,[2|[3|[]]],[1|[2|[]]])
Trace: >> REDO:   safe(4,-2,[])
Trace: >> FAIL:   safe(4,-2,[])
Trace: >> REDO:   -2 is 1 - 3
Trace: >> FAIL:   DOWN$135 is 1 - 3
Trace: >> REDO:   4 is 1 + 3
Trace: >> FAIL:   UP$134 is 1 + 3
Trace: >> REDO:   choose(3,[1|[2|[3|[]]]],[1|[2|[]]])
Trace: >> REDO:   choose(3,[2|[3|[]]],[2|[]])
Trace: >> REDO:   choose(3,[3|[]],[])
Trace: >> CALL:   choose(COL$132,[],T2$166)
Trace: >> FAIL:   choose(COL$132,[],T2$166)
Trace: >> FAIL:   choose(COL$132,[3|[]],T2$154)
Trace: >> FAIL:   choose(COL$132,[2|[3|[]]],T2$147)
Trace: >> FAIL:   choose(COL$132,[1|[2|[3|[]]]],C$133)
Trace: >> FAIL:   solve([],SOLUTONS$131,[1|[2|[3|[]]]],[1|[2|[3|[]]]])
Trace: >> REDO:   inlist(3,[],[1|[2|[3|[]]]])
Trace: >> REDO:   inlist(2,[3|[]],[1|[2|[3|[]]]])
Trace: >> REDO:   inlist(1,[2|[3|[]]],[1|[2|[3|[]]]])
Trace: >> CALL:   1 > 1
Trace: >> FAIL:   1 > 1
Trace: >> FAIL:   inlist(1,[2|[3|[]]],L$128)
Trace: >> REDO:   1 is 2 - 1
Trace: >> FAIL:   Y$130 is 2 - 1
Trace: >> REDO:   2 > 1
Trace: >> FAIL:   2 > 1
Trace: >> FAIL:   inlist(2,[3|[]],L$128)
Trace: >> REDO:   2 is 3 - 1
Trace: >> FAIL:   Y$129 is 3 - 1
Trace: >> REDO:   3 > 1
Trace: >> FAIL:   3 > 1
Trace: >> FAIL:   inlist(3,[],L$128)
Trace: >> FAIL:   queens(3,SOLUTIONS$
顶端 Posted: 2006-10-25 16:34 | [楼 主]
五栋楼



性别: 帅哥 状态: 该用户目前不在线
头衔: hspidence
等级: 人见人爱
家族: 跑跑UesTc家族
发贴: 2611
威望: 0
浮云: 2672
在线等级:
注册时间: 2006-09-12
最后登陆: 2012-08-25

5come5帮你背单词 [ buzz /bΛz/ v. 嗡嗡声,蜂音,嘁嘁喳喳的声音,蜂鸣器;vi. 发嗡嗡声,嘁嘁喳喳地讲 ]


没见到过啊
顶端 Posted: 2006-10-25 18:17 | [1 楼]
albert





性别: 保密 状态: 该用户目前不在线
等级: 栋梁之材
家族: 唯war独尊
发贴: 634
威望: 0
浮云: 1116
在线等级:
注册时间: 2005-10-04
最后登陆: 2012-02-12

5come5帮你背单词 [ sulfate // n. 硫酸盐 ]


LZ啥意思呀?
顶端 Posted: 2006-10-25 19:13 | [2 楼]
albert





性别: 保密 状态: 该用户目前不在线
等级: 栋梁之材
家族: 唯war独尊
发贴: 634
威望: 0
浮云: 1116
在线等级:
注册时间: 2005-10-04
最后登陆: 2012-02-12

5come5帮你背单词 [ do /du:, du/ a. 做,完成,产生,做行动,进行,可以 ]


LZ啥意思呀?
顶端 Posted: 2006-10-25 19:14 | [3 楼]
demonwar



年度之星奖
性别: 帅哥 状态: 该用户目前不在线
头衔: 头你妹的
等级: 管理员
家族: 存在与虚无
发贴: 52925
威望: 11
浮云: 1406
在线等级:
注册时间: 2006-08-02
最后登陆: 2018-06-18

5come5帮你背单词 [ disagree /disə'gri:/ vi. 不符,不一致,不同意,争执,不适合 ]


难道是英文阐释的题目。。
顶端 Posted: 2006-10-25 19:20 | [4 楼]
2004



性别: 帅哥 状态: 该用户目前不在线
等级: 品行端正
发贴: 222
威望: 0
浮云: 1107
在线等级:
注册时间: 2006-09-25
最后登陆: 2011-10-25

5come5帮你背单词 [ eligible /'elid3əbl/ a. 有资格的,合格的,适宜的 ]


解释一下sai
顶端 Posted: 2006-11-05 16:13 | [5 楼]
yvhydn



性别: 保密 状态: 该用户目前不在线
等级: 栋梁之材
家族: 考研俱乐部
发贴: 604
威望: 1
浮云: 1117
在线等级:
注册时间: 2004-06-03
最后登陆: 2008-03-06

5come5帮你背单词 [ mature /mə'tjuə/ a. 成熟的,理智的,慎重的;v. 成熟 ]


看不懂
顶端 Posted: 2006-11-05 21:45 | [6 楼]
我来我网·5come5 Forum » 程序员之家

Total 0.011445(s) query 5, Time now is:11-24 05:50, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号