Topic: Help: random number generation


Author: steve@hway.com
Date: 1995/07/05
Raw View
I am attempting to write some code which generates several random numbers between 1 and 21..
I am using Borland Turbo C++ (V 3.0) ; here's a snipet of code which does compile without errors --
it's the result I am not happy with:
----------
// usual include(s)

int i, num[10];

randomize();

for (i = 1; i <= 10; i++){
 num[i] = random(21);
 cout << num[i] << "\n";
 }

// etc
-----------
After running the program a few times, it is apparent that there is a trend with at least the first number
generated.
(ie 1 1 2 2 2 3 3...)  Wihtout careful scrutiny, I wouldn't notice the trend because the other numbers seem
varied.

I'd like to mix it up a bit -- it doesn't quite appear to be random.
Can anyone please offer some assistance.?

Thanks
-----
Steve Rogers
steve@hway.com

NEW:  Imagemap Help Page (IHiP)
      resource for HTML and image authors
      http://www.hway.com/ihip/

(If I have posted to the wrong group, please let me know.)