#include <stdio.h>
int plot[8][8];
char *state[] = {" ", "○ ", "● "};
char *hands[] = {"", "先攻", "後攻"};
// prototype
void print_board();
void print_board()
{
int x, y;
printf("\033[2J");
printf("\033[%d;%dH", 0, 0);
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
printf("%s|", state[plot[x][y]]);
}
printf("\n");
printf("--+--+--+--+--+--+--+--+\n");
}
}
int main()
{
int x, y,hand = 1;
char buf[100];
while (1) {
do {
print_board();
printf("hand = %s\n", hands[hand]);
printf("終了 = q\n" );
printf("x y = " );
fgets(buf, 100, stdin);
if (buf[0]=='q' | buf[0]=='Q') {
printf("終了します\n" );
return 0;
}
sscanf(buf, "%d%d", &x, &y);
} while (x < 0 | x > 7 | y < 0 | y > 7);
if (plot[x][y] == 0) {
plot[x][y] = hand;
hand = 3 - hand;
}
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CmludCBwbG90WzhdWzhdOwpjaGFyICpzdGF0ZVtdID0geyLjgIAiLCAi4peLICIsICLil48gIn07CmNoYXIgKmhhbmRzW10gPSB7IiIsICLlhYjmlLsiLCAi5b6M5pS7In07CgovLyBwcm90b3R5cGUKdm9pZCBwcmludF9ib2FyZCgpOwoKdm9pZCBwcmludF9ib2FyZCgpCnsKICBpbnQgeCwgeTsKICBwcmludGYoIlwwMzNbMkoiKTsKICBwcmludGYoIlwwMzNbJWQ7JWRIIiwgMCwgMCk7CiAgZm9yICh5ID0gMDsgeSA8IDg7IHkrKykgewogICAgZm9yICh4ID0gMDsgeCA8IDg7IHgrKykgewogICAgICBwcmludGYoIiVzfCIsIHN0YXRlW3Bsb3RbeF1beV1dKTsKICAgIH0KICAgIHByaW50ZigiXG4iKTsKICAgIHByaW50ZigiLS0rLS0rLS0rLS0rLS0rLS0rLS0rLS0rXG4iKTsKICB9Cn0KCmludCBtYWluKCkKewogIGludCB4LCB5LGhhbmQgPSAxOwogIGNoYXIgYnVmWzEwMF07CgogIHdoaWxlICgxKSB7CiAgICBkbyB7CiAgICAgIHByaW50X2JvYXJkKCk7CiAgICAgIHByaW50ZigiaGFuZCA9ICVzXG4iLCBoYW5kc1toYW5kXSk7CiAgICAgIHByaW50Zigi57WC5LqGID0gcVxuIiApOwogICAgICBwcmludGYoInggeSA9ICIgKTsKICAgICAgZmdldHMoYnVmLCAxMDAsIHN0ZGluKTsKICAgICAgaWYgKGJ1ZlswXT09J3EnIHwgYnVmWzBdPT0nUScpIHsKICAgICAgICBwcmludGYoIue1guS6huOBl+OBvuOBmVxuIiApOwogICAgICAgIHJldHVybiAwOwogICAgICB9CiAgICAgIHNzY2FuZihidWYsICIlZCVkIiwgJngsICZ5KTsKICAgIH0gd2hpbGUgKHggPCAwIHwgeCA+IDcgfCB5IDwgMCB8IHkgPiA3KTsKICAgIGlmIChwbG90W3hdW3ldID09IDApIHsKICAgICAgcGxvdFt4XVt5XSA9IGhhbmQ7CiAgICAgIGhhbmQgPSAzIC0gaGFuZDsKICAgIH0KICB9CgogIHJldHVybiAwOwp9Cg==