samedi 16 mai 2015

Fill array with random numbers but with limits

I am trying to add random values to an array. The user has to say how many values (length) and give the minval and maxval (e.x. minval = 3 means no values under 3). This is what I've got:

int[] GetallenArray;

public IntegerArray(int length, int maxval, int minval) {

    this.GetallenArray = new int[length];
    for (int i = 0; i < GetallenArray.length; i++)
    {
        this.GetallenArray[i] = // Random values between the maxval and minval
    }
}




Aucun commentaire:

Enregistrer un commentaire