Repeat
readln (guess);
if (guess<max) and (guess>min) then
begin
if guess>answer then
max:=guess;
if guess<answer then
min:=guess;
end;
if (guess>max) or (guess<min) then
begin
ClrScr;
Writeln ('[Get It At Once]');
Delay(1000);
Writeln ('Please mind the range!(',min, '-',max,')');
Delay(1000);
Writeln ('Input another number please~');
end;
Until (guess<max) and (guess>min);
Randomize;
random_num:= Random(random(max-min))+min;
rec := 0;
win := TRUE;
Repeat
rec := rec+1;
write('Input a number: ');readln(num);
if (num>max) or (num<min)
thenrepeat
writeln('*****************************************************************');
writeln('The input number ',num,' is not in the range of',min, ' - ', max);
writeln('Please input another number: ');readln(num);
until (num<max) and (num>min);
if num < random_num
then begin
writeln('*****************************************************************');
writeln('Incorrect! The number is too small.');
min := num;
writeln('The range is ',min,' - ', max);
writeln('You have inputted ',rec,' time');
writeln('Please try again');
end
else if num > random_num
then begin
writeln('************************************************************');
writeln('Incorrect! The number is too large.');
max := num;
writeln('The range is ',min, ' - ', max);
writeln('You have inputted ',rec,' time');
writeln('Please try again');
end
else begin
writeln('******************************************************');
writeln('You are correct! The answer is ',random_num);
writeln('You have inputted ',rec,' time');
win := FALSE;
end;
if win
then begin
com := random(random(max-min))+min+1;
writeln('**********************************************************');
writeln('The number computer guests is ',com);
if com < random_num
then begin
min := com;
writeln('The range is ',min,' - ', max);
end
else if com > random_num
then begin
writeln('****************************************************');
max := com;
writeln('The range is ',min, ' - ', max);
end
else begin
writeln('********************************************************');
writeln('The computer is correct! The answer is ',random_num);
writeln('You are lose!!!');
end
end
until (num = random_num) or (com = random_num)
end
歡迎光臨 香港寵物小精靈村落 論壇 (https://proxy.archiver.hkpnve.pokebeacon.com/) | Powered by Discuz! X3.2 |