hello.i am new here.
i have a homework. i'm using turbo pascal. and i'm trying to learn TP
and make my homework.
my homework is gueesing the random number which the computer keeps. i
can get a random number which has 4 digits with this code:
program randomnum;
uses crt;
var
randomnumber:integer;
k,l,m,n,i:integer;
begin
clrscr;
while (1<>2) do
begin
k:=random(9)+1;
l:=random(10);
m:=random(10);
n:=random(10);
if ((k<>l) and (l<>m) and (m<>n)and (k<>m) and(k<>n)and(l<>n)) then
begin
i:=k*1000+l*100+m*10+n; break;
end;
end;
randomsayi:=i;
readkey;
end.
the player mustn't see this number and then the player has to start to
guess. if 2 digits are true, my program must write +2,0.
if some numbers are correct but not at the right digit,for example
computer's number is 1234,and i wrote 6741, my program must write
-2,0.because digits are not at the right place.or if random number is
1234 and i wrote 9231,it must write (+2,-1)
some digits are true but 1 is not at it's right place.
if all numbers and digits are wrong, it must write 0,and if every
digits and numbers are true,it must write +4.
have you sample codes about this program?
sorry because of my english.
thanks.
oya the beatlefan