RSS Forums RSS
Please support our C++ advertiser: Programming Forums

Help needed filling array with unique random numbers

Join Date: Apr 2007
Posts: 7
Reputation: bling_bling_vr6 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
bling_bling_vr6 bling_bling_vr6 is offline Offline
Newbie Poster

Re: Help needed filling array with unique random numbers

  #10  
Apr 15th, 2007
Holy Schneikes!

That's it!!! Thanks a million infarction!

for(int i = 0; i < MAXSIZE; i++)
{
do {
temp = rand() % 5000; // get random number
} while (LinearSearch(list, temp) != -1); // repeat till it's unique
list[i] = temp; // save it
}
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:55 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC