|
-
Jul 30th, 2008, 05:02 AM
#1
Thread Starter
Frenzied Member
creating a list of unsorted numbers
i have an editbox in which i can enter a number between 1000-5000
and i need to create a list/array of unsorted numbers.
for e.g, if i enter 1500 in the box and click on the button 'Start'
it should create an array/list of numbers 1,2,3,....,1500 (but all mixed up)
any ideas guys?
-
Jul 30th, 2008, 01:50 PM
#2
Fanatic Member
Re: creating a list of unsorted numbers
Generate the list in order first. Then create a new blank list. Have another list that contains which spots are open. Generate a random number from 0 to the size of the last list mentioned and place the next number in the first list in it. Then remove that from the list of possibilities and generate again.
C#.net, VB, C++, Java, VS 2005/2008
Dont' forget to rate posts that are helpful to you.
-
Aug 1st, 2008, 04:11 PM
#3
Hyperactive Member
Re: creating a list of unsorted numbers
I think a more efficient way would be to check out
Collections.shuffle()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|