質問編集履歴
1
試した内容
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,3 +21,31 @@
|
|
21
21
|
の場合、2と4を出したいのですが、まったくうまくいきません。
|
22
22
|
|
23
23
|
よろしくお願いします。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
こんな感じで試してみました。
|
28
|
+
|
29
|
+
public int[] maxIndex(int[] a) {
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
int ma = a[0];
|
34
|
+
|
35
|
+
int[] mai = new int[a.length];
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
for(int i = 0; i < a.length; i++) {
|
40
|
+
|
41
|
+
if(ma < a[i]) {
|
42
|
+
|
43
|
+
mai[i] = i;
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
return mai;
|
50
|
+
|
51
|
+
}
|