Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Random numbers with no repeat
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bmass




PostPosted: Sun Dec 10, 2006 4:10 pm   Post subject: Random numbers with no repeat

Hey there, I need to randomly generate 16 numbers from 0 - 15, but they must all be different. Essentially I need to generate the numbers from 0 - 15 in a random order. I also need to do it multiple times. If anyone could help me with this it would be greatly appreciated. Thanks.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Dec 10, 2006 4:15 pm   Post subject: (No subject)

use an array to keep the numbers not yet picked, then randomly pick a position in the array and take that number out. Repeat until your array size is 0.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: