質問編集履歴
1
書式の改善を行いました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,260 +20,258 @@
|
|
20
20
|
|
21
21
|
というエラーメッセージが出てしまいました。
|
22
22
|
|
23
|
+
|
24
|
+
|
25
|
+
### 該当のソースコード
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
```Java
|
30
|
+
|
31
|
+
import java.util.*;
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
public class IVpazzle{
|
36
|
+
|
37
|
+
public static void main(String[] args) {
|
38
|
+
|
39
|
+
System.out.printf(" IVsupporter ver%1.1f%n ", 1.0);
|
40
|
+
|
41
|
+
System.out.println("注:自然Vが発生している個体値はサポートされていません");
|
42
|
+
|
43
|
+
System.out.println();
|
44
|
+
|
45
|
+
System.out.println("ポケモンのV固定数を入力してください");
|
46
|
+
|
47
|
+
int Vnum = new Scanner(System.in).nextInt();
|
48
|
+
|
49
|
+
if (Vnum < 0 || Vnum > 5){
|
50
|
+
|
51
|
+
System.out.println("値が不正です");
|
52
|
+
|
53
|
+
System.exit(0);
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
System.out.println(" ポケモンの個体値を入力してください(例:x x x x x x)");
|
58
|
+
|
59
|
+
String IV = new Scanner(System.in).nextLine();
|
60
|
+
|
61
|
+
String Array[] = IV.split(" ");
|
62
|
+
|
63
|
+
int H = Integer.parseInt(Array[0]);
|
64
|
+
|
65
|
+
int A = Integer.parseInt(Array[1]);
|
66
|
+
|
67
|
+
int B = Integer.parseInt(Array[2]);
|
68
|
+
|
69
|
+
int C = Integer.parseInt(Array[3]);
|
70
|
+
|
71
|
+
int D = Integer.parseInt(Array[4]);
|
72
|
+
|
73
|
+
int S = Integer.parseInt(Array[5]);
|
74
|
+
|
75
|
+
if (H < 0 || H > 31 || A < 0 || A > 31 || B < 0 || B > 31 || C < 0 || C > 31 || D < 0 || D > 31 || S < 0 || S > 31){
|
76
|
+
|
77
|
+
System.out.println("値が不正です");
|
78
|
+
|
79
|
+
System.exit(0);
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
else if (!(H == 31) && (H % 8 == 0)){
|
84
|
+
|
85
|
+
H = 31;
|
86
|
+
|
87
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
else if (!(H == 31) && (H % 8 == 1) && !(A == 31)){
|
92
|
+
|
93
|
+
A = 31;
|
94
|
+
|
95
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
else if (!(H == 31) && (H % 8 == 2) && !(B == 31)){
|
100
|
+
|
101
|
+
B = 31;
|
102
|
+
|
103
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
else if (!(H == 31) && (H % 8 == 3) && !(C == 31)){
|
108
|
+
|
109
|
+
C = 31;
|
110
|
+
|
111
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
else if (!(H == 31) && (H % 8 == 4) && !(D == 31)){
|
116
|
+
|
117
|
+
D = 31;
|
118
|
+
|
119
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
else if (!(H == 31) && (H % 8 == 5) && !(S == 31)){
|
124
|
+
|
125
|
+
S = 31;
|
126
|
+
|
127
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
else if (!(H == 31) && (H % 8 == 1) && (A == 31) ){
|
134
|
+
|
135
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
else if (!(H == 31) && (H % 8 == 2) && (B == 31)){
|
140
|
+
|
141
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
else if (!(H == 31) && (H % 8 == 3) && (C == 31)){
|
146
|
+
|
147
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
else if (!(H == 31) && (H % 8 == 4) && (D == 31)){
|
152
|
+
|
153
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
else if (!(H == 31) && (H % 8 == 5) && (S == 31)){
|
158
|
+
|
159
|
+
int[] IVf = recalc(H, A, B, C, D, S);
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
public static int[] recalc(int H, int A, int B, int C, int D, int S){
|
168
|
+
|
169
|
+
LinkedList<Integer> num = new LinkedList<Integer>();
|
170
|
+
|
171
|
+
if (!(H == 31))
|
172
|
+
|
173
|
+
num.add(H);
|
174
|
+
|
175
|
+
else if (!(A == 31))
|
176
|
+
|
177
|
+
num.add(A);
|
178
|
+
|
179
|
+
else if (!(B == 31))
|
180
|
+
|
181
|
+
num.add(B);
|
182
|
+
|
183
|
+
else if (!(C == 31))
|
184
|
+
|
185
|
+
num.add(C);
|
186
|
+
|
187
|
+
else if (!(D == 31))
|
188
|
+
|
189
|
+
num.add(D);
|
190
|
+
|
191
|
+
else if (!(S == 31))
|
192
|
+
|
193
|
+
num.add(S);
|
194
|
+
|
195
|
+
num.remove(0);
|
196
|
+
|
197
|
+
int[] IV = new int[6];
|
198
|
+
|
199
|
+
IV[0] = H;
|
200
|
+
|
201
|
+
IV[1] = A;
|
202
|
+
|
203
|
+
IV[2] = B;
|
204
|
+
|
205
|
+
IV[3] = C;
|
206
|
+
|
207
|
+
IV[4] = D;
|
208
|
+
|
209
|
+
IV[5] = S;
|
210
|
+
|
211
|
+
for (int r = 0; r <= num.size(); r++){
|
212
|
+
|
213
|
+
if ( !(IV[0] == 31)){
|
214
|
+
|
215
|
+
IV[0] = num.get(0);
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
else if ((IV[0] == 31) && !(IV[1] == 31)){
|
220
|
+
|
221
|
+
IV[1] = num.get(0);
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
else if ((IV[0] == 31) && (IV[1] == 31) && !(IV[2] == 31)){
|
226
|
+
|
227
|
+
IV[2] = num.get(0);
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
else if ((IV[0] == 31) && (IV[1] == 31) && (IV[2] == 31) && !(IV[3] == 31)){
|
232
|
+
|
233
|
+
IV[3] = num.get(0);
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
else if ((IV[0] == 31) && (IV[1] == 31) && (IV[2] == 31) && (IV[3] == 31) && !(IV[4] == 31)){
|
238
|
+
|
239
|
+
IV[4] = num.get(0);
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
else if ((IV[0] == 31) && (IV[1] == 31) && (IV[2] == 31) && (IV[3] == 31) && (IV[4] == 31) && !(IV[5] == 31)){
|
244
|
+
|
245
|
+
IV[5] = num.get(0);
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
num.remove(0);
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
System.out.print(IV[0] + " ");
|
254
|
+
|
255
|
+
System.out.print(IV[1] + " ");
|
256
|
+
|
257
|
+
System.out.print(IV[2] + " ");
|
258
|
+
|
259
|
+
System.out.print(IV[3] + " ");
|
260
|
+
|
261
|
+
System.out.print(IV[4] + " ");
|
262
|
+
|
263
|
+
System.out.print(IV[5] + " ");
|
264
|
+
|
265
|
+
return IV;
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
}
|
270
|
+
|
23
271
|
```
|
24
272
|
|
25
273
|
|
26
274
|
|
27
|
-
### 該当のソースコード
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
```Java
|
32
|
-
|
33
|
-
import java.util.*;
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
public class IVpazzle{
|
38
|
-
|
39
|
-
public static void main(String[] args) {
|
40
|
-
|
41
|
-
System.out.printf(" IVsupporter ver%1.1f%n ", 1.0);
|
42
|
-
|
43
|
-
System.out.println("注:自然Vが発生している個体値はサポートされていません");
|
44
|
-
|
45
|
-
System.out.println();
|
46
|
-
|
47
|
-
System.out.println("ポケモンのV固定数を入力してください");
|
48
|
-
|
49
|
-
int Vnum = new Scanner(System.in).nextInt();
|
50
|
-
|
51
|
-
if (Vnum < 0 || Vnum > 5){
|
52
|
-
|
53
|
-
System.out.println("値が不正です");
|
54
|
-
|
55
|
-
System.exit(0);
|
56
|
-
|
57
|
-
}
|
58
|
-
|
59
|
-
System.out.println(" ポケモンの個体値を入力してください(例:x x x x x x)");
|
60
|
-
|
61
|
-
String IV = new Scanner(System.in).nextLine();
|
62
|
-
|
63
|
-
String Array[] = IV.split(" ");
|
64
|
-
|
65
|
-
int H = Integer.parseInt(Array[0]);
|
66
|
-
|
67
|
-
int A = Integer.parseInt(Array[1]);
|
68
|
-
|
69
|
-
int B = Integer.parseInt(Array[2]);
|
70
|
-
|
71
|
-
int C = Integer.parseInt(Array[3]);
|
72
|
-
|
73
|
-
int D = Integer.parseInt(Array[4]);
|
74
|
-
|
75
|
-
int S = Integer.parseInt(Array[5]);
|
76
|
-
|
77
|
-
if (H < 0 || H > 31 || A < 0 || A > 31 || B < 0 || B > 31 || C < 0 || C > 31 || D < 0 || D > 31 || S < 0 || S > 31){
|
78
|
-
|
79
|
-
System.out.println("値が不正です");
|
80
|
-
|
81
|
-
System.exit(0);
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
else if (!(H == 31) && (H % 8 == 0)){
|
86
|
-
|
87
|
-
H = 31;
|
88
|
-
|
89
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
else if (!(H == 31) && (H % 8 == 1) && !(A == 31)){
|
94
|
-
|
95
|
-
A = 31;
|
96
|
-
|
97
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
else if (!(H == 31) && (H % 8 == 2) && !(B == 31)){
|
102
|
-
|
103
|
-
B = 31;
|
104
|
-
|
105
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
106
|
-
|
107
|
-
}
|
108
|
-
|
109
|
-
else if (!(H == 31) && (H % 8 == 3) && !(C == 31)){
|
110
|
-
|
111
|
-
C = 31;
|
112
|
-
|
113
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
else if (!(H == 31) && (H % 8 == 4) && !(D == 31)){
|
118
|
-
|
119
|
-
D = 31;
|
120
|
-
|
121
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
else if (!(H == 31) && (H % 8 == 5) && !(S == 31)){
|
126
|
-
|
127
|
-
S = 31;
|
128
|
-
|
129
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
else if (!(H == 31) && (H % 8 == 1) && (A == 31) ){
|
136
|
-
|
137
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
else if (!(H == 31) && (H % 8 == 2) && (B == 31)){
|
142
|
-
|
143
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
144
|
-
|
145
|
-
}
|
146
|
-
|
147
|
-
else if (!(H == 31) && (H % 8 == 3) && (C == 31)){
|
148
|
-
|
149
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
150
|
-
|
151
|
-
}
|
152
|
-
|
153
|
-
else if (!(H == 31) && (H % 8 == 4) && (D == 31)){
|
154
|
-
|
155
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
else if (!(H == 31) && (H % 8 == 5) && (S == 31)){
|
160
|
-
|
161
|
-
int[] IVf = recalc(H, A, B, C, D, S);
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
}
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
public static int[] recalc(int H, int A, int B, int C, int D, int S){
|
170
|
-
|
171
|
-
LinkedList<Integer> num = new LinkedList<Integer>();
|
172
|
-
|
173
|
-
if (!(H == 31))
|
174
|
-
|
175
|
-
num.add(H);
|
176
|
-
|
177
|
-
else if (!(A == 31))
|
178
|
-
|
179
|
-
num.add(A);
|
180
|
-
|
181
|
-
else if (!(B == 31))
|
182
|
-
|
183
|
-
num.add(B);
|
184
|
-
|
185
|
-
else if (!(C == 31))
|
186
|
-
|
187
|
-
num.add(C);
|
188
|
-
|
189
|
-
else if (!(D == 31))
|
190
|
-
|
191
|
-
num.add(D);
|
192
|
-
|
193
|
-
else if (!(S == 31))
|
194
|
-
|
195
|
-
num.add(S);
|
196
|
-
|
197
|
-
num.remove(0);
|
198
|
-
|
199
|
-
int[] IV = new int[6];
|
200
|
-
|
201
|
-
IV[0] = H;
|
202
|
-
|
203
|
-
IV[1] = A;
|
204
|
-
|
205
|
-
IV[2] = B;
|
206
|
-
|
207
|
-
IV[3] = C;
|
208
|
-
|
209
|
-
IV[4] = D;
|
210
|
-
|
211
|
-
IV[5] = S;
|
212
|
-
|
213
|
-
for (int r = 0; r <= num.size(); r++){
|
214
|
-
|
215
|
-
if ( !(IV[0] == 31)){
|
216
|
-
|
217
|
-
IV[0] = num.get(0);
|
218
|
-
|
219
|
-
}
|
220
|
-
|
221
|
-
else if ((IV[0] == 31) && !(IV[1] == 31)){
|
222
|
-
|
223
|
-
IV[1] = num.get(0);
|
224
|
-
|
225
|
-
}
|
226
|
-
|
227
|
-
else if ((IV[0] == 31) && (IV[1] == 31) && !(IV[2] == 31)){
|
228
|
-
|
229
|
-
IV[2] = num.get(0);
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
else if ((IV[0] == 31) && (IV[1] == 31) && (IV[2] == 31) && !(IV[3] == 31)){
|
234
|
-
|
235
|
-
IV[3] = num.get(0);
|
236
|
-
|
237
|
-
}
|
238
|
-
|
239
|
-
else if ((IV[0] == 31) && (IV[1] == 31) && (IV[2] == 31) && (IV[3] == 31) && !(IV[4] == 31)){
|
240
|
-
|
241
|
-
IV[4] = num.get(0);
|
242
|
-
|
243
|
-
}
|
244
|
-
|
245
|
-
else if ((IV[0] == 31) && (IV[1] == 31) && (IV[2] == 31) && (IV[3] == 31) && (IV[4] == 31) && !(IV[5] == 31)){
|
246
|
-
|
247
|
-
IV[5] = num.get(0);
|
248
|
-
|
249
|
-
}
|
250
|
-
|
251
|
-
num.remove(0);
|
252
|
-
|
253
|
-
}
|
254
|
-
|
255
|
-
System.out.print(IV[0] + " ");
|
256
|
-
|
257
|
-
System.out.print(IV[1] + " ");
|
258
|
-
|
259
|
-
System.out.print(IV[2] + " ");
|
260
|
-
|
261
|
-
System.out.print(IV[3] + " ");
|
262
|
-
|
263
|
-
System.out.print(IV[4] + " ");
|
264
|
-
|
265
|
-
System.out.print(IV[5] + " ");
|
266
|
-
|
267
|
-
return IV;
|
268
|
-
|
269
|
-
}
|
270
|
-
|
271
|
-
}
|
272
|
-
|
273
|
-
```
|
274
|
-
|
275
|
-
|
276
|
-
|
277
275
|
### 試したこと
|
278
276
|
|
279
277
|
|