domains
A,B,C = symbol
N,P = integer
predicates
tower(integer,symbol,symbol,symbol,integer)
go
clauses
go :- clearwindow,
write("enter value of N (For Transfering from A To B)"),
readint(N),
tower(N,'a','b','c',N).
tower(N,A,B,C,P):-
N > 1,
P is N-1
tower(P,A,C,B,P),
write([move , A,B]),nl,
tower(P,C,B,A,P).
tower(0,_,_,_):- !.
最佳答案
您在 P is N-1
之后缺少一个逗号。
关于prolog - 我正在使用古老的涡轮序言。并在以下代码中不断面临错误 :- mis-spelling or not declared predicate ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5754061/