program Project1;{$APPTYPE CONSOLE} uses Sysutils; const Max=100; var rn, un, cnt: Integer; guess: Boolean; begin Randomize; rn := Trunc(Random(Max) + 1); WriteLn('from 1 to '+inttostr(Max)+',guess!'); WriteLn('Your guess is: '); cnt := 1; //un := 0; Guess := False; while Guess = False do begin ReadLn(un); if un > rn then WriteLn('Wrong, it is smaller ') else if un < rn then WriteLn('Wrong, it is larger') else //un=rn begin Guess:=True; Writeln('Correct!'+ IntToStr(cnt)+' times !') end; cnt := cnt + 1; end; //while ReadLn; //don't close the window, wait for [Enter] end.
uses
Sysutils;
const
Max=100;
var
rn, un, cnt: Integer;
guess: Boolean;
begin
Randomize;
rn := Trunc(Random(Max) + 1);
WriteLn('from 1 to '+inttostr(Max)+',guess!');
WriteLn('Your guess is: ');
cnt := 1;
//un := 0;
Guess := False;
while Guess = False do
begin
ReadLn(un);
if un > rn then
WriteLn('Wrong, it is smaller ')
else if un < rn then
WriteLn('Wrong, it is larger')
else //un=rn
begin
Guess:=True;
Writeln('Correct!'+ IntToStr(cnt)+' times !')
end;
cnt := cnt + 1;
end; //while
ReadLn; //don't close the window, wait for [Enter]
end.