質問編集履歴
5
修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,7 +42,7 @@
|
|
42
42
|
|
43
43
|
```java
|
44
44
|
|
45
|
-
public class Quick {
|
45
|
+
public class QuickSort {
|
46
46
|
|
47
47
|
|
48
48
|
|
4
修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,9 +28,9 @@
|
|
28
28
|
|
29
29
|
at java.base/java.util.ArrayList.get(ArrayList.java:426)
|
30
30
|
|
31
|
-
at Quick.Quick
|
31
|
+
at Quick.Quick(Quick.java:24)
|
32
32
|
|
33
|
-
at Quick.Quick
|
33
|
+
at Quick.Quick(Quick.java:35)
|
34
34
|
|
35
35
|
```
|
36
36
|
|
3
修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,9 +28,9 @@
|
|
28
28
|
|
29
29
|
at java.base/java.util.ArrayList.get(ArrayList.java:426)
|
30
30
|
|
31
|
-
at
|
31
|
+
at Quick.Quick1(Quick.java:24)
|
32
32
|
|
33
|
-
at
|
33
|
+
at Quick.Quick1(Quick.java:35)
|
34
34
|
|
35
35
|
```
|
36
36
|
|
2
ご指摘頂いた部分を修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,27 +16,21 @@
|
|
16
16
|
|
17
17
|
```
|
18
18
|
|
19
|
-
Exception in thread "main" java.lang.
|
19
|
+
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
|
20
20
|
|
21
|
-
at java.base/ja
|
21
|
+
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
|
22
22
|
|
23
|
-
at java.base/ja
|
23
|
+
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
|
24
24
|
|
25
|
-
at java.base/ja
|
25
|
+
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
|
26
26
|
|
27
|
-
at java.base/java.util.
|
27
|
+
at java.base/java.util.Objects.checkIndex(Objects.java:373)
|
28
28
|
|
29
|
-
at java.base/java.util.ArrayList.
|
29
|
+
at java.base/java.util.ArrayList.get(ArrayList.java:426)
|
30
30
|
|
31
|
-
at Quick.Quick(Quick.java:2
|
31
|
+
at kadai7.S7018534_Quick.Quick1(S7018534_Quick.java:24)
|
32
32
|
|
33
|
-
at Quick.Quick(Quick.java:3
|
33
|
+
at kadai7.S7018534_Quick.Quick1(S7018534_Quick.java:35)
|
34
|
-
|
35
|
-
at Quick.Quick(Quick.java:34)
|
36
|
-
|
37
|
-
at Quick.Quick(Quick.java:34)
|
38
|
-
|
39
|
-
...
|
40
34
|
|
41
35
|
```
|
42
36
|
|
@@ -78,9 +72,9 @@
|
|
78
72
|
|
79
73
|
int P = array.get(0);
|
80
74
|
|
81
|
-
for (int i=
|
75
|
+
for (int i=1; i<size; i++) {
|
82
76
|
|
83
|
-
if (P >
|
77
|
+
if (P > array.get(i)) {
|
84
78
|
|
85
79
|
L.add(array.get(i));
|
86
80
|
|
@@ -108,21 +102,21 @@
|
|
108
102
|
|
109
103
|
//分割した値を統合
|
110
104
|
|
111
|
-
int i
|
105
|
+
for (int i=0; i<L.size(); i++) {
|
112
106
|
|
113
|
-
|
107
|
+
array.add(L.get(i));
|
114
108
|
|
115
|
-
|
109
|
+
}
|
116
110
|
|
117
|
-
array.add(R.get(indexR)); indexR++;
|
118
111
|
|
119
|
-
}
|
120
112
|
|
121
|
-
|
113
|
+
array.add(P);
|
122
114
|
|
123
|
-
array.add(L.get(indexL)); indexL++;
|
124
115
|
|
116
|
+
|
117
|
+
for (int i=0; i<R.size(); i++) {
|
118
|
+
|
125
|
-
|
119
|
+
array.add(R.get(i));
|
126
120
|
|
127
121
|
}
|
128
122
|
|
1
すみません。こちらにミスです。
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
//クイックソート
|
60
60
|
|
61
|
-
void Quick
|
61
|
+
void Quick(ArrayList<Integer> array) {
|
62
62
|
|
63
63
|
int size = array.size();
|
64
64
|
|
@@ -114,13 +114,13 @@
|
|
114
114
|
|
115
115
|
if (indexL == L.size()) {
|
116
116
|
|
117
|
-
array
|
117
|
+
array.add(R.get(indexR)); indexR++;
|
118
118
|
|
119
119
|
}
|
120
120
|
|
121
121
|
else if (indexR == R.size()) {
|
122
122
|
|
123
|
-
array
|
123
|
+
array.add(L.get(indexL)); indexL++;
|
124
124
|
|
125
125
|
}
|
126
126
|
|