dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Array of random numbers ...

  1. #1
    Join Date
    Nov 2010
    Posts
    2

    Array of random numbers ...

    a little problem I have , well I have to make an array which generates 50 numbers from 0 to 999 which I can manage that the problem lies with the part were the numbers generatet cant be the same here is what ive done so far





    [CODE]
    import java.util.Random;
    public class ArrayRandom{
    public static void main(String args[]
    {
    Random r = new Random();
    int temp;
    int arr[] = new int[50];
    for(int i = 0; i < 50; i++)
    {

    temp = r.nextInt(999) + 1; // this will give you a random number between 0 to 999.

    arr[i] = temp; //here we know that the number is unique, so we can put it inside arr[i]
    }
    for(int i = 0; i < 50; i++)
    {
    System.out.print(arr[i] + " ");
    }
    }


    }
    [\CODE]



    if some one could help me this would be a great help thanx shane : )

  2. #2
    Join Date
    Mar 2010
    Posts
    16

  3. #3
    Join Date
    Nov 2010
    Posts
    2

    Re: Array of random numbers ...

    thanx to who has helped but i am having help elsewhere sorry for time wasting

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)