質問編集履歴
2
コードの場所を修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,340 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
コード
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
#include <stdio.h>
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
int board[8][8];
|
12
|
+
|
13
|
+
void turnLeftUp1(int x,int y){
|
14
|
+
|
15
|
+
if(y>1 && x>1){
|
16
|
+
|
17
|
+
if(board[y][x]==2 && board[y-1][x-1]==1){
|
18
|
+
|
19
|
+
for(int k=2;;k++){
|
20
|
+
|
21
|
+
if(x-k<0 || y-k<0){
|
22
|
+
|
23
|
+
break;
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
if(board[y-k][x-k]==0){
|
28
|
+
|
29
|
+
board[y-k][x-k]=3;
|
30
|
+
|
31
|
+
break;
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
void turnUp1(int x, int y){
|
46
|
+
|
47
|
+
if(y>1){
|
48
|
+
|
49
|
+
if(board[y][x]==2 && board[y-1][x]==1){
|
50
|
+
|
51
|
+
for(int k=2;;k++){
|
52
|
+
|
53
|
+
if(y-k<0){
|
54
|
+
|
55
|
+
break;
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
if(board[y-k][x]==0){
|
60
|
+
|
61
|
+
board[y-k][x]=3;
|
62
|
+
|
63
|
+
break;
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
void turnRightUp1(int x, int y){
|
78
|
+
|
79
|
+
if(y>1 && x<6){
|
80
|
+
|
81
|
+
if(board[y][x]==2 && board[y-1][x+1]==1){
|
82
|
+
|
83
|
+
for(int k=2;;k++){
|
84
|
+
|
85
|
+
if(x+k>7||y-k<0){
|
86
|
+
|
87
|
+
break;
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
if(board[y-k][x+k]==0){
|
92
|
+
|
93
|
+
board[y-k][x+k]=3;
|
94
|
+
|
95
|
+
break;
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
void turnDown1(int x,int y){
|
110
|
+
|
111
|
+
if(y<6){
|
112
|
+
|
113
|
+
if(board[y][x]==2 && board[y+1][x]==1){
|
114
|
+
|
115
|
+
for(int k=2;;k++){
|
116
|
+
|
117
|
+
if(y+k>7){
|
118
|
+
|
119
|
+
break;
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
if(board[y+k][x]==0){
|
124
|
+
|
125
|
+
board[y+k][x]=3;
|
126
|
+
|
127
|
+
break;
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
void turnRight1(int x, int y){
|
140
|
+
|
141
|
+
if(x<6){
|
142
|
+
|
143
|
+
if(board[y][x]==2 && board[y][x+1]==1){
|
144
|
+
|
145
|
+
for(int k=2;;k++){
|
146
|
+
|
147
|
+
if(x+k>7){
|
148
|
+
|
149
|
+
break;
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
if(board[y][x+k]==0){
|
154
|
+
|
155
|
+
board[y][x+k]=3;
|
156
|
+
|
157
|
+
break;
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
void turnLeftDown1(int x,int y){
|
170
|
+
|
171
|
+
if(y<6 && x>1){
|
172
|
+
|
173
|
+
if(board[y][x]==2 && board[y+1][x-1]==1){
|
174
|
+
|
175
|
+
for(int k=2;;k++){
|
176
|
+
|
177
|
+
if(x-k<0||y+k>7){
|
178
|
+
|
179
|
+
break;
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
if(board[y+k][x-k]==0){
|
184
|
+
|
185
|
+
board[y+k][x-k]=3;
|
186
|
+
|
187
|
+
break;
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
void turnLeft(int x,int y){
|
200
|
+
|
201
|
+
if(x>1){
|
202
|
+
|
203
|
+
if(board[y][x]==2 && board[y][x-1]==1){
|
204
|
+
|
205
|
+
for(int k=2;;k++){
|
206
|
+
|
207
|
+
if(x<k) break;
|
208
|
+
|
209
|
+
if(board[y][x-k]==0){
|
210
|
+
|
211
|
+
board[y][x-k]=3;
|
212
|
+
|
213
|
+
break;
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
void turnRightDown1(int x,int y){
|
228
|
+
|
229
|
+
if(y<6 && x<6){
|
230
|
+
|
231
|
+
if(board[y][x]==2 && board[y+1][x+1]==1){
|
232
|
+
|
233
|
+
for(int k=2;;k++){
|
234
|
+
|
235
|
+
if(x+k > 7|| y+k > 7){
|
236
|
+
|
237
|
+
break;
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
if(board[y+k][x+k]==0){
|
242
|
+
|
243
|
+
board[y+k][x+k]=3;
|
244
|
+
|
245
|
+
break;
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
int main(int argc, char **argv)
|
264
|
+
|
265
|
+
{
|
266
|
+
|
267
|
+
FILE *fp;
|
268
|
+
|
269
|
+
int i, j;
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
if (argc != 2) {
|
274
|
+
|
275
|
+
return 1;
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
fp = fopen(argv[1], "r");
|
282
|
+
|
283
|
+
if (fp ==NULL) {
|
284
|
+
|
285
|
+
return 1;
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
for (i=0; i<8; i++) {
|
292
|
+
|
293
|
+
for (j=0; j<8; j++) {
|
294
|
+
|
295
|
+
fscanf(fp, "%d", &(board[i][j]));
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
for (i=0; i<8; i++) {
|
304
|
+
|
305
|
+
for (j=0; j<8; j++) {
|
306
|
+
|
307
|
+
turnLeftUp1(i,j);
|
308
|
+
|
309
|
+
turnUp1(i,j);
|
310
|
+
|
311
|
+
turnRightUp1(i,j);
|
312
|
+
|
313
|
+
turnLeft(i,j);
|
314
|
+
|
315
|
+
turnRight1(i,j);
|
316
|
+
|
317
|
+
turnLeftDown1(i,j);
|
318
|
+
|
319
|
+
turnDown1(i,j);
|
320
|
+
|
321
|
+
turnRightDown1(i,j);
|
322
|
+
|
323
|
+
printf("%d ", board[i][j]);
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
printf("\n");
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
return 0;
|
334
|
+
|
1
|
-
#
|
335
|
+
}# 前提・実現したいこと
|
336
|
+
|
337
|
+
|
2
338
|
|
3
339
|
|
4
340
|
|
@@ -60,361 +396,7 @@
|
|
60
396
|
|
61
397
|
|
62
398
|
|
63
|
-
|
399
|
+
|
64
|
-
|
65
|
-
ソースコード
|
66
|
-
|
67
|
-
読み込むファイル
|
68
|
-
|
69
|
-
0 0 0 0 0 0 0 0
|
70
|
-
|
71
|
-
0 0 0 0 0 0 0 0
|
72
|
-
|
73
|
-
0 0 0 0 1 2 0 0
|
74
|
-
|
75
|
-
0 0 0 1 1 2 0 0
|
76
|
-
|
77
|
-
0 0 0 2 2 1 0 0
|
78
|
-
|
79
|
-
0 0 0 0 0 0 1 0
|
80
|
-
|
81
|
-
0 0 0 0 0 0 0 0
|
82
|
-
|
83
|
-
0 0 0 0 0 0 0 0
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
ソースコード
|
88
|
-
|
89
|
-
#include <stdio.h>
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
int board[8][8];
|
94
|
-
|
95
|
-
void turnLeftUp1(int x,int y){
|
96
|
-
|
97
|
-
if(y>1 && x>1){
|
98
|
-
|
99
|
-
if(board[y][x]==2 && board[y-1][x-1]==1){
|
100
|
-
|
101
|
-
for(int k=2;;k++){
|
102
|
-
|
103
|
-
if(x-k<0 || y-k<0){
|
104
|
-
|
105
|
-
break;
|
106
|
-
|
107
|
-
}
|
108
|
-
|
109
|
-
if(board[y-k][x-k]==0){
|
110
|
-
|
111
|
-
board[y-k][x-k]=3;
|
112
|
-
|
113
|
-
break;
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
}
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
void turnUp1(int x, int y){
|
128
|
-
|
129
|
-
if(y>1){
|
130
|
-
|
131
|
-
if(board[y][x]==2 && board[y-1][x]==1){
|
132
|
-
|
133
|
-
for(int k=2;;k++){
|
134
|
-
|
135
|
-
if(y-k<0){
|
136
|
-
|
137
|
-
break;
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
if(board[y-k][x]==0){
|
142
|
-
|
143
|
-
board[y-k][x]=3;
|
144
|
-
|
145
|
-
break;
|
146
|
-
|
147
|
-
}
|
148
|
-
|
149
|
-
}
|
150
|
-
|
151
|
-
}
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
}
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
void turnRightUp1(int x, int y){
|
160
|
-
|
161
|
-
if(y>1 && x<6){
|
162
|
-
|
163
|
-
if(board[y][x]==2 && board[y-1][x+1]==1){
|
164
|
-
|
165
|
-
for(int k=2;;k++){
|
166
|
-
|
167
|
-
if(x+k>7||y-k<0){
|
168
|
-
|
169
|
-
break;
|
170
|
-
|
171
|
-
}
|
172
|
-
|
173
|
-
if(board[y-k][x+k]==0){
|
174
|
-
|
175
|
-
board[y-k][x+k]=3;
|
176
|
-
|
177
|
-
break;
|
178
|
-
|
179
|
-
}
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
void turnDown1(int x,int y){
|
192
|
-
|
193
|
-
if(y<6){
|
194
|
-
|
195
|
-
if(board[y][x]==2 && board[y+1][x]==1){
|
196
|
-
|
197
|
-
for(int k=2;;k++){
|
198
|
-
|
199
|
-
if(y+k>7){
|
200
|
-
|
201
|
-
break;
|
202
|
-
|
203
|
-
}
|
204
|
-
|
205
|
-
if(board[y+k][x]==0){
|
206
|
-
|
207
|
-
board[y+k][x]=3;
|
208
|
-
|
209
|
-
break;
|
210
|
-
|
211
|
-
}
|
212
|
-
|
213
|
-
}
|
214
|
-
|
215
|
-
}
|
216
|
-
|
217
|
-
}
|
218
|
-
|
219
|
-
}
|
220
|
-
|
221
|
-
void turnRight1(int x, int y){
|
222
|
-
|
223
|
-
if(x<6){
|
224
|
-
|
225
|
-
if(board[y][x]==2 && board[y][x+1]==1){
|
226
|
-
|
227
|
-
for(int k=2;;k++){
|
228
|
-
|
229
|
-
if(x+k>7){
|
230
|
-
|
231
|
-
break;
|
232
|
-
|
233
|
-
}
|
234
|
-
|
235
|
-
if(board[y][x+k]==0){
|
236
|
-
|
237
|
-
board[y][x+k]=3;
|
238
|
-
|
239
|
-
break;
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
}
|
244
|
-
|
245
|
-
}
|
246
|
-
|
247
|
-
}
|
248
|
-
|
249
|
-
}
|
250
|
-
|
251
|
-
void turnLeftDown1(int x,int y){
|
252
|
-
|
253
|
-
if(y<6 && x>1){
|
254
|
-
|
255
|
-
if(board[y][x]==2 && board[y+1][x-1]==1){
|
256
|
-
|
257
|
-
for(int k=2;;k++){
|
258
|
-
|
259
|
-
if(x-k<0||y+k>7){
|
260
|
-
|
261
|
-
break;
|
262
|
-
|
263
|
-
}
|
264
|
-
|
265
|
-
if(board[y+k][x-k]==0){
|
266
|
-
|
267
|
-
board[y+k][x-k]=3;
|
268
|
-
|
269
|
-
break;
|
270
|
-
|
271
|
-
}
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
}
|
276
|
-
|
277
|
-
}
|
278
|
-
|
279
|
-
}
|
280
|
-
|
281
|
-
void turnLeft(int x,int y){
|
282
|
-
|
283
|
-
if(x>1){
|
284
|
-
|
285
|
-
if(board[y][x]==2 && board[y][x-1]==1){
|
286
|
-
|
287
|
-
for(int k=2;;k++){
|
288
|
-
|
289
|
-
if(x<k) break;
|
290
|
-
|
291
|
-
if(board[y][x-k]==0){
|
292
|
-
|
293
|
-
board[y][x-k]=3;
|
294
|
-
|
295
|
-
break;
|
296
|
-
|
297
|
-
}
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
}
|
302
|
-
|
303
|
-
}
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
}
|
308
|
-
|
309
|
-
void turnRightDown1(int x,int y){
|
310
|
-
|
311
|
-
if(y<6 && x<6){
|
312
|
-
|
313
|
-
if(board[y][x]==2 && board[y+1][x+1]==1){
|
314
|
-
|
315
|
-
for(int k=2;;k++){
|
316
|
-
|
317
|
-
if(x+k > 7|| y+k > 7){
|
318
|
-
|
319
|
-
break;
|
320
|
-
|
321
|
-
}
|
322
|
-
|
323
|
-
if(board[y+k][x+k]==0){
|
324
|
-
|
325
|
-
board[y+k][x+k]=3;
|
326
|
-
|
327
|
-
break;
|
328
|
-
|
329
|
-
}
|
330
|
-
|
331
|
-
}
|
332
|
-
|
333
|
-
}
|
334
|
-
|
335
|
-
}
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
int main(int argc, char **argv)
|
346
|
-
|
347
|
-
{
|
348
|
-
|
349
|
-
FILE *fp;
|
350
|
-
|
351
|
-
int i, j;
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
if (argc != 2) {
|
356
|
-
|
357
|
-
return 1;
|
358
|
-
|
359
|
-
}
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
fp = fopen(argv[1], "r");
|
364
|
-
|
365
|
-
if (fp ==NULL) {
|
366
|
-
|
367
|
-
return 1;
|
368
|
-
|
369
|
-
}
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
for (i=0; i<8; i++) {
|
374
|
-
|
375
|
-
for (j=0; j<8; j++) {
|
376
|
-
|
377
|
-
fscanf(fp, "%d", &(board[i][j]));
|
378
|
-
|
379
|
-
}
|
380
|
-
|
381
|
-
}
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
for (i=0; i<8; i++) {
|
386
|
-
|
387
|
-
for (j=0; j<8; j++) {
|
388
|
-
|
389
|
-
turnLeftUp1(i,j);
|
390
|
-
|
391
|
-
turnUp1(i,j);
|
392
|
-
|
393
|
-
turnRightUp1(i,j);
|
394
|
-
|
395
|
-
turnLeft(i,j);
|
396
|
-
|
397
|
-
turnRight1(i,j);
|
398
|
-
|
399
|
-
turnLeftDown1(i,j);
|
400
|
-
|
401
|
-
turnDown1(i,j);
|
402
|
-
|
403
|
-
turnRightDown1(i,j);
|
404
|
-
|
405
|
-
printf("%d ", board[i][j]);
|
406
|
-
|
407
|
-
}
|
408
|
-
|
409
|
-
printf("\n");
|
410
|
-
|
411
|
-
}
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
return 0;
|
416
|
-
|
417
|
-
}
|
418
400
|
|
419
401
|
### 試したこと
|
420
402
|
|
1
コードの場所を修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,7 +54,7 @@
|
|
54
54
|
|
55
55
|
エラーメッセージ
|
56
56
|
|
57
|
-
|
57
|
+
間に白が2つ続くときに該当箇所に3を表示することが出来ません。
|
58
58
|
|
59
59
|
|
60
60
|
|
@@ -62,18 +62,8 @@
|
|
62
62
|
|
63
63
|
### 該当のソースコード
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
C言語
|
70
|
-
|
71
|
-
```ここに言語名を入力
|
72
|
-
|
73
65
|
ソースコード
|
74
66
|
|
75
|
-
```
|
76
|
-
|
77
67
|
読み込むファイル
|
78
68
|
|
79
69
|
0 0 0 0 0 0 0 0
|
@@ -432,7 +422,7 @@
|
|
432
422
|
|
433
423
|
ここに問題に対して試したことを記載してください。
|
434
424
|
|
435
|
-
|
425
|
+
|
436
426
|
|
437
427
|
|
438
428
|
|