Search the web
Sign In
New User? Sign Up
turbopascalprogramming2 · Pascal / Delphi Programming , Mugen ni
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
can you help me???   Message List  
Reply | Forward Message #1243 of 1332 |
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






Tue Nov 15, 2005 12:38 pm

beatle_oya
Offline Offline
Send Email Send Email

Forward
Message #1243 of 1332 |
Expand Messages Author Sort by Date

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...
Oya
beatle_oya
Offline Send Email
Nov 15, 2005
12:38 pm

You should consider using some small arrays, and loops to scan their content, rather than agonising over complicated if-statements with a collection of...
Nicky
rnmclean
Offline Send Email
Nov 16, 2005
8:18 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help