-1
目標: 在上面給出的代碼中應用一個循環,以便它會詢問「你想繼續嗎? (是/否)「,然後採取相應措施。 (提示:做一個謂詞'再次/ 0'做上面的任務)。我是序言新手,我被困在一個程序中
go:-
write('What is the name of Patient?'),
read(Patient),nl,
hypo(Patient, Disease),
write(Patient),
write(' probably has '),
write(Disease),nl.
go:-
write('Sorry I am unable to diagnose the Disease.'),nl.
hypo(Patient,flu):-
sym(Patient,fever),
sym(Patient,cough).
hypo(Patient,headche):-
sym(Patient,bodypain).
sym(Patient,fever):-
write(' Does '),
write(Patient),
write(' has fever (y/n)?'),
res(R), R='y'.
sym(Patient,cough):-
write('Does '),
write(Patient),
write(' has cough (y/n)?'),
res(R), R='y'.
sym(Patient,bodypain):-
write('Does '),
write(Patient),
write(' has bodypain (y/n)?'),
res(R), R='y'.
res(R):-
read(R),nl.
你忘了提出一個問題。你要求我們做作業嗎? – CapelliC
你可以這樣說。:| –