Results 1 to 3 of 3

Thread: creating a list of unsorted numbers

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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?

  2. #2
    Fanatic Member
    Join Date
    Jun 2003
    Location
    Worcester, MA
    Posts
    782

    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.

  3. #3
    Hyperactive Member pgag45's Avatar
    Join Date
    Mar 2007
    Location
    Colorado
    Posts
    262

    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
  •  



Click Here to Expand Forum to Full Width