mercredi 20 juillet 2016

How to add +1 to each element of array till a maximum value(which is known beforehand)?

I have an array for tables:

 int[] tables = new int[9]

I want to make it so each int in this array is the number of persons a table can have. int[9] so 10 tables in total.

If i have a maximum of 98 players i want the array to contain:

tables[0] = 10
tables[1] = 10
tables[2] = 10
tables[3] = 10
tables[4] = 10
tables[5] = 10
tables[6] = 10
tables[7] = 10
tables[8] = 9
tables[9] = 9

the sum of all ^ this is 98 now.

The array values are all 0 at the beginning, they have to add up till it reaches a sum of 98, the 98 can also be different, sometimes its 97, 96 etc. thanks.

Aucun commentaire:

Enregistrer un commentaire