#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void input(int* n, char z)
{
while (1) {
printf("%c座標を入力してください(0-3) >", z
); scanf_s("%d", n);
if (0 <= *n && *n < 4) {
break;
}
}
}
int main()
{
int field[4 * 4] = {0};
int bomb[2];
int x, y;
int round;
for (round = 1; round <= 15; ) {
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
printf("%d ", field
[y
* 4 + x
]); }
}
printf("round %d\n", round
, bomb
[0], bomb
[1]); input(&x, 'x');
input(&y, 'y');
if (field[y * 4 + x]) {
continue;
}
if (x == bomb[0] && y == bomb[1]) {
return 0;
}
field[y * 4 + x] = 1;
round++;
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KCnZvaWQgaW5wdXQoaW50KiBuLCBjaGFyIHopCnsKCXdoaWxlICgxKSB7CgkJcHJpbnRmKCIlY+W6p+aomeOCkuWFpeWKm+OBl+OBpuOBj+OBoOOBleOBhCgwLTMpID4iLCB6KTsKCQlzY2FuZl9zKCIlZCIsIG4pOwoJCWlmICgwIDw9ICpuICYmICpuIDwgNCkgewoJCQlicmVhazsKCQl9CgkJcHJpbnRmKCLnr4Tlm7LlpJbjgafjgZlcbiIpOwoJfQp9CgppbnQgbWFpbigpCnsKCWludAlmaWVsZFs0ICogNF0gPSB7MH07CglpbnQJYm9tYlsyXTsKCWludAl4LCB5OwoJaW50CXJvdW5kOwoKCXNyYW5kKCh1bnNpZ25lZCl0aW1lKE5VTEwpKTsKCWJvbWJbMF0gPSByYW5kKCkgJSA0OwoJYm9tYlsxXSA9IHJhbmQoKSAlIDQ7CgoJZm9yIChyb3VuZCA9IDE7IHJvdW5kIDw9IDE1OyApIHsKCQlmb3IgKHkgPSAwOyB5IDwgNDsgeSsrKSB7CgkJCWZvciAoeCA9IDA7IHggPCA0OyB4KyspIHsKCQkJCXByaW50ZigiJWQgIiwgZmllbGRbeSAqID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