回答編集履歴
1
別解
test
CHANGED
@@ -111,3 +111,109 @@
|
|
111
111
|
}
|
112
112
|
|
113
113
|
```
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
---
|
118
|
+
|
119
|
+
n * mの配列は、[i/n][i%m]で0から+1づつで順にアクセスできます。
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
なので、今回のように等差であるなら、
|
124
|
+
|
125
|
+
forの中身を、score[i/5][i%5]にして、
|
126
|
+
|
127
|
+
初期値と増減値を調整するだけですべて表示できます。
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
```java
|
132
|
+
|
133
|
+
for(int i = 0; i < 5; i++) {
|
134
|
+
|
135
|
+
System.out.print(score[i/5][i%5] + " ");
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
System.out.println();
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
for(int i = 1; i < 22; i+=5) {
|
144
|
+
|
145
|
+
System.out.print(score[i/5][i%5] + " ");
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
System.out.println();
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
for(int i = 12; i < 15; i++) {
|
154
|
+
|
155
|
+
System.out.print(score[i/5][i%5] + " ");
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
System.out.println();
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
for(int i = 9; 5 <= i; i--) {
|
164
|
+
|
165
|
+
System.out.print(score[i/5][i%5] + " ");
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
System.out.println();
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
for(int i = 0; i < 25; i+=6) {
|
174
|
+
|
175
|
+
System.out.print(score[i/5][i%5] + " ");
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
System.out.println();
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
for(int i = 24; 0 <= i; i-=6) {
|
184
|
+
|
185
|
+
System.out.print(score[i/5][i%5] + " ");
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
System.out.println();
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
for(int i = 1; i < 20; i+=6) {
|
194
|
+
|
195
|
+
System.out.print(score[i/5][i%5] + " ");
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
System.out.println();
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
for(int i = 0; i < 25; i+=12) {
|
204
|
+
|
205
|
+
System.out.print(score[i/5][i%5] + " ");
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
System.out.println();
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
for(int i = 0; i < 15; i+=7) {
|
214
|
+
|
215
|
+
System.out.print(score[i/5][i%5] + " ");
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
```
|