Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- int main()
- {
- int wkx, wky, wrx, wry, bkx, bky;
- char s[10];
- gets(s);
- wkx = s[0] - 97;
- wky = s[1] - 49;
- wrx = s[3] - 97;
- wry = s[4] - 49;
- bkx = s[6] - 97;
- bky = s[7] - 49;
- int kingattack[8][8] = {0};
- int rookattack[8][8] = {0};
- for (int dx = -1; dx <= 1; dx++)
- for (int dy = -1; dy <= 1; dy++)
- if (dx != 0 or dy != 0)
- {
- int xx = wkx + dx;
- int yy = wky + dy;
- if (xx < 0 or xx >= 8 or yy < 0 or yy >= 8) continue;
- kingattack[xx][yy] = 1;
- }
- for (int i = 0; i < 8; i++) rookattack[wrx][i] = rookattack[i][wry] = 1;
- bool attacked = rookattack[bkx][bky];
- bool canmove = false;
- for (int dx = -1; dx <= 1; dx++)
- for (int dy = -1; dy <= 1; dy++)
- if (dx != 0 or dy != 0)
- {
- int xx = bkx + dx;
- int yy = bky + dy;
- if (xx < 0 or xx >= 8 or yy < 0 or yy >= 8) continue;
- canmove |= (kingattack[xx][yy] ^ 1) & (rookattack[xx][yy] ^ 1);
- }
- if (kingattack[bkx][bky]) puts("Strange");
- else if (!attacked and canmove) puts("Normal");
- else if (attacked and canmove) puts("Check");
- else if (!attacked and !canmove) puts("Stalemate");
- else if (attacked and !canmove) puts("Checkmate");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement