mercredi 25 mai 2016

How to fill an array with smaller arrays in a random way?

I've got an array with 225 elements and 15 smaller arrays which their length sum is exactly 225.

The point is that I need to fill the larger array with these smaller arrays but in a random way.

 private final short datosdeNivel[]= new short[225];
 private final short diecinueve[]= {19, 19};
 private final short veintiseis[]= {26, 26, 26};
 private final short dieciocho[]= {18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18};
 private final short veintidos[]= {22, 22};
 private final short veintiuno[]={21, 21, 21, 21, 21, 21, 21, 21, 21, 21};
 private final short cero[]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 private final short diecisiete[]= {17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17};
 private final short dieciseis[]= {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,16, 16, 16, 16, 16, 16, 16, 16, 16, 16,16, 16, 16, 16, 16, 16, 16, 16, 16, 16,16, 16, 16, 16, 16, 16, 16, 16, 16, 16,16, 16, 16, 16, 16, 16, 16, 16, 16, 16,16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
 private final short veinte[]= {20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20};
 private final short veinticuatro[]= {24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24};
 private final short veinticinco[]= {25, 25, 25, 25};
 private final short veintiocho[]= {28, 28};
 private final short uno[]= {1, 1, 1, 1, 1, 1, 1};
 private final short nueve[]= {1};
 private final short ocho[]= {9, 9, 9, 9, 9, 9, 9, 9, 9};

How can I establish a random order so every time the program runs the order in which the smaller arrays are placed in the larger array is different?




Aucun commentaire:

Enregistrer un commentaire