mercredi 8 février 2017

Adding random numbers 1-1000000 in an array?

I have looked up how to add 0-99 to an array. But, my assignment was 1-1000000. I just keep getting really large numbers and no small numbers. Is it just because the chance of getting large numbers is a lot higher? I just wanted to make sure I was doing it right. Thanks in advance for any help!

 int a[]= new int[50];
    for(int i = 0; i < 50; i++){
        a[i] = (int)(Math.random() * 10000000);
    }




Aucun commentaire:

Enregistrer un commentaire