0
最小值我有以下代碼如何找到在序言
option(2):-
write('Enter place of origin: '), read(Origin),
write('Enter place of destination: '), read(Destination),
path(Origin, Destination, Path, Length),nl,nl,
printPath(Path), write(' '),
writef(' TOTAL DISTANCE = %d', [Length]),nl,fail;true.
,我想找到的長度中的最小值。我得到的輸出與此類似
bahirdar-->mota TOTAL DISTANCE = 100
bahirdar-->markos-->mota TOTAL DISTANCE = 70
最小路徑,見庫([集合](HTTP://www.swi-prolog .ORG/pldoc /人?部=集合體))。那麼你可以聚合(min(L,Path),Origin^Destination^Path^path(Origin,Destination,Path,L),Length)。 – CapelliC