Answer the question
In order to leave comments, you need to log in
How to display the largest sum and array number?
public static int func() {
for (int i = 1; i < 10; i++) {
int[] a = new int[15];
int s = 0;
for (int j = 0; j < a.length; j++) {
a[j] = (int) (Math.random() * 20);
s = s + a[j];
}
System.out.print(" Array -- " + Arrays.toString(a));
System.out.println(" -- " + (s));
}
return 0;
}
And it turns out --- Array -- [10, 4, 7, 6, 17, 11, 2, 16, 7, 11, 18, 14, 6, 13, 13] -- 155
Array -- [1, 13, 4, 8, 0, 11, 1, 16, 9, 10, 3, 8, 14, 15, 9] -- 122
Array -- [7, 6, 14, 7, 12, 14, 1, 6, 17, 11, 16, 19, 17, 4, 17] -- 168
Array -- [13, 8, 14, 12, 10 , 17, 9, 13, 0, 19, 13, 6, 13, 12, 1] -- 160
Array -- [9, 12, 17, 3, 13, 7, 4, 11, 2, 2, 16, 13, 10, 16, 6] -- 141
Array -- [12, 10, 0, 11, 17, 5, 15, 18, 5, 2, 5, 0, 0, 12, 13] -- 125
Array - - [19, 14, 19, 1, 5, 7, 12, 0, 6, 4, 17, 7, 19, 10, 1] -- 141
Array -- [13, 13, 2, 18, 18, 4 , 1, 1, 17, 18, 18, 4, 16, 12, 1] -- 156
Array -- [10, 11, 5, 14, 10, 11, 0, 1, 10, 7, 6, 2, 1, 1, 16] -- 105.
I can't figure out how to make them count and the array where the largest amount was displayed
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question