Board index » delphi » Help with a random number generator...
Meldrum
![]() Delphi Developer |
Sun, 17 Aug 2003 14:12:14 GMT
|
Meldrum
![]() Delphi Developer |
Sun, 17 Aug 2003 14:12:14 GMT
Help with a random number generator...
Hi everyone. I am a C++ programmer and this is my first shot at a Pascal
program. I need a random number generator to produce integers in a range 0..k. In C++, I would usually write the following: #include <time.h> What are the Pascal equivalents to the seed (srand) function and the rand meldru...@hotmail.com |
Sven Pra
![]() Delphi Developer |
Sun, 17 Aug 2003 16:54:03 GMT
Re:Help with a random number generator...Quote"Meldrum" <dsa...@hotmail.com> wrote in message Quote> Hi everyone. I am a C++ programmer and this is my first shot at a Pascal Then you use the RANDOM function for each new random number to be generated. If you call RANDOM without any argument then you receive a real number In your case you would call RANDOM with an integer argument which must R := RANDOM(RMAX); returns an integer in the range 0 <= R < RMAX regards Sven - Hide quoted text - - Show quoted text - Quote
|
Dr John Stockto
![]() Delphi Developer |
Sun, 17 Aug 2003 21:27:28 GMT
Re:Help with a random number generator...JRS: In article <97i5al$orl5...@ID-55178.news.dfncis.de>, seen in news:comp.lang.pascal.borland, Meldrum <dsa...@hotmail.com> wrote at Tue, 27 Feb 2001 22:12:14 :- Quote>Hi everyone. I am a C++ programmer and this is my first shot at a Pascal Pascal products. Try looking up Random in the manuals or the on-line help. BTW, seeding a RNG to the time has dangers, if your program can get -- |
Rudolf Polz
![]() Delphi Developer |
Mon, 18 Aug 2003 23:22:40 GMT
Re:Help with a random number generator...Dr John Stockton <s...@merlyn.demon.co.uk> schrieb Folgendes: Quote> JRS: In article <97i5al$orl5...@ID-55178.news.dfncis.de>, seen in write std:: before each library object! Quote> >srand((unsigned) time (NULL)); //seeds rng to the time C Pascal -- |