var wrong, UNum1, UNum2, UNum3, UNum4, CNum1, CNum2, CNum3, CNum4 : int
wrong:=5
randint (CNum1,0,1)
randint (CNum2,0,1)
randint (CNum3,0,1)
randint (CNum4,0,1)
loop
put "enter a four digit binary code one didget at a time"
cls
put "you have " ,wrong, " chances left"
get UNum1, UNum2, UNum3, UNum4
put UNum1, UNum2, UNum3, UNum4
if CNum1 not=UNum1 then
wrong := wrong-1
else
wrong:=wrong+1
end if
if CNum2 not= UNum2 then
wrong := wrong-1
else
wrong:=wrong+1
end if
if CNum3 not= UNum3 then
wrong := wrong-1
else
wrong := wrong+1
end if
if CNum4 not= UNum4 then
wrong := wrong-1
else
end if
exit when wrong < 1 or UNum1=CNum1 and UNum2=CNum2 and UNum3=CNum3 and UNum4=CNum4
end loop
if wrong < 1 then
put "you lose, the number was " ,CNum1,CNum2,CNum3,CNum4
else
put "you win"
end if
|