vendredi 27 mars 2015

Function to generate 2D array with random, non repeating numbers with range of 99

I need to create a function which generates a 2D array of random non repeating numbers with a predefined range of 1 - 99.



static Random RandomGenerator = new Random();

int[][] ran_array ={
new int [10],
new int [10],
new int [10]
};


I was thinking of using 2 loops within a function to go through each array, and then each list within the array to add in the numbers, so the output would look something like this



static Random RandomGenerator = new Random();

int[][] ran_array ={
new int [1, 3, 5, 7, 9, 2, 4, 7, 9, 10],
new int [23, 24, 12, 53, 75, 87, 20, 12, 25, 11],
new int [11, 54, 74, 67, 32, 87, 23, 98, 31, 1]
};


How would I go about doing this?





Aucun commentaire:

Enregistrer un commentaire