我来我网
https://5come5.cn
您尚未
登录
注册
|
菠菜
|
软件站
|
音乐站
|
邮箱1
|
邮箱2
|
风格选择
|
更多 »
vista
鍙よ壊涔﹂
card
wind
绮夌孩濂抽儙
帮助
统计与排行
无图版
我来我网·5come5 Forum
»
电脑技术
»
程序员之家
»
求助---一个N-皇后求解问题
交 易
投 票
本页主题:
求助---一个N-皇后求解问题
显示签名
|
打印
|
加为IE收藏
|
收藏主题
|
上一主题
|
下一主题
战无敌平琼宇
∷
性别:
保密
∷
状态:
∷
等级:
鹤立鸡群
∷
家族:
低调一族
∷
发贴:
1135
∷
威望:
0
∷
浮云:
1126
∷
在线等级:
∷
注册时间: 2006-08-17
∷
最后登陆: 2007-06-11
【
复制此帖地址
只看此人回复
】
5come5帮你背单词 [
implication
/impli'kei
∫
ə
n/
n. 暗示,暗指,言外之意,牵连
]
求助---一个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 |
[楼 主]
demonwar
∷
性别:
∷
状态:
∷
头衔:
头你妹的
∷
等级:
管理员
∷
家族:
存在与虚无
∷
发贴:
52925
∷
威望:
11
∷
浮云:
1406
∷
在线等级:
∷
注册时间: 2006-08-02
∷
最后登陆: 2018-06-18
【
复制此帖地址
只看此人回复
】
5come5帮你背单词 [
dial
/'dai
ə
l/
n. (钟表等的)针盘,(电话的)拨号盘,刻度盘;v. 拨(电话号码),打(电话)
]
难道是英文阐释的题目。。
Posted: 2006-10-25 19:20 |
[1 楼]
快速跳至
|- 站务管理
|- 惩罚,奖励公布区
|- 会员咨询意见区
|- 申请区
|- 已批准申请区
|- 威望和荣誉会员推荐区
|- 5come5名人堂·Hall of Fame
>> 休闲娱乐
|- 灌水乐园 大杂烩
|- 精水区
|- 幽默天地
|- 开怀大笑(精华区)
|- 灵异空间
|- 运动新时空·菠菜交流
|- 动之风.漫之舞
|- 新货上架
|- 古董挖挖
|- 唯美贴图
|- 创意&美化&设计
|- 5COME5头像及签名档图片引用专区
|- 艺术摄影
|- 音乐咖啡屋
|- 音道乐经
>> 热点讨论
|- 工作交流
|- 求职信息
|- 就业精华区
|- 同城联谊
|- 留学专版
|- 情感物语
|- 情感物语精华区
|- 带走一片银杏叶
|- 精华区
|- 新闻直通车
|- 众志成城,抗震救灾
|- 衣食住行
|- 跳蚤市场
|- 旅游出行
>> 学术交流
|- 学业有成
|- 智力考场
|- 考研专版
|- 外语乐园
|- 考试·毕业设计
|- 电子设计·数学建模
|- 学生工作·社团交流·RX
|- 电脑技术
|- 电脑F.A.Q.
|- 软件交流
|- 硬件·数码
|- 程序员之家
|- Linux专区
|- 舞文弄墨
|- 历史&文化
|- 军临天下
|- 军事精华区
|- 财经频道
>> 游戏新干线[电子竞技俱乐部]
|- Blizz@rd游戏特区
|- WarCraft III
|- 魔兽区档案库
|- 魔兽争霸3博彩专区
|- StarCraft(new)
|- 暗黑专区
|- 休闲游戏区
|- PC GAME综合讨论区
|- 实况足球专区
|- Counter-Strike专区
|- TV GAME& 模拟器
|- 网络游戏
>> 资源交流
|- 恋影部落
|- 连续剧天地
|- 综艺开心档
|- 书香小筑
|- 小说发布
|- 资源交流
|- 综艺、体育、游戏资源发布
|- 音乐资源发布区
|- 电影电视剧发布区
|- 字幕园地
我来我网·5come5 Forum
»
程序员之家
Total 0.007813(s) query 6, Time now is:11-24 02:26, Gzip enabled
Powered by PHPWind v5.3, Localized by
5come5 Tech Team
,
黔ICP备16009856号