クイズプログラム1


※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

cans(0,['Q0:','1.XXX','2.YYY','3.ZZZ'],1).
cans(1,['Q1:','1.XXX','2.YYY','3.ZZZ'],1).
cans(2,['Q2:','1.XXX','2.YYY','3.ZZZ'],1).
cans(3,['Q3:','1.XXX','2.YYY','3.ZZZ'],1).
cans(4,['Q4:','1.XXX','2.YYY','3.ZZZ'],1).
cans(5,['Q5:','1.XXX','2.YYY','3.ZZZ'],1).
cans(6,['Q6:','1.XXX','2.YYY','3.ZZZ'],1).
 
 
test:-
	clause(cans,3,N),write(N),
	NN is N-1,
	repeat(I),q(I),I=:=NN,
	ansr(NN,SUM),
	rate(N,SUM).
 
q(N):-
	cans(N,QWORD,ANSNO),
	writenl(QWORD),nl,
	ttyget(X),
	name(XX,[X]),
	qcheck(XX,ANSNO,YY),
	assert(myans(N,XX,ANSNO,YY)).
 
ansr(-1,0):- !.
ansr(N,SSum):-
	NN is N -1,
	ansr(NN,Sum),
 
	myans(N,YA,TA,CK), 
	ansck(CK,Sum,SSum),
	write_listnl(['Q',N,':','Your answer=',YA,'.The answer=',TA,':',CK]).
 
rate(NN,SUM):-R is SUM/NN,write_listnl(['Qcount=',NN,',AnsCount',SUM,',Rate=',R]).
 
 
 
writenl([]):- !.
writenl([A|L]):-
	write(A),nl,
	writenl(L).
 
qcheck(A1,A1,'○').
qcheck(A1,A2,'×').
 
ansck('○',Sum,SSum):- SSum is Sum +1.
ansck('×',Sum,Sum).