View Single Post
 
Reply
Posted 2004-11-07, 04:16 PM in reply to deadlock75's post "Rand() function seeded srand(time(0)"
Sorry, I'm not really sure what you asked either. I looked at your code, and the only thing I could comprehend from your question that makes sense would be that you want to fill up an array of, say, 20 slots with random integers frm 1-100, in order to sort them afterwards or whatnot.

Well, I see numbers[i]=rand();

rand()%100 will give a random integer from 0 to 99, so use this line to get 1-100 inputted into a slot of your array:

numbers[i]=rand()%100+1;

Not sure if that's what you meant. It's been too long since I dealt with this. I recall writing a new randomizer function way back that took a min and max parameter, kind of like the PHP function. Not that it really matters, it just takes some basic math skills to figure out your range.

Now that I see your other post about QuickSort, my answer feels too basic.
"Stephen Wolfram is the creator of Mathematica and is widely regarded as the most important innovator in scientific and technical computing today." - Stephen Wolfram

Last edited by Chruser; 2004-11-07 at 04:21 PM.
Old
Profile PM WWW Search
Chruser never puts off to tomorrow what can be done the day after tomorrowChruser never puts off to tomorrow what can be done the day after tomorrowChruser never puts off to tomorrow what can be done the day after tomorrowChruser never puts off to tomorrow what can be done the day after tomorrowChruser never puts off to tomorrow what can be done the day after tomorrow
 
 
Chruser