Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <string>
- #define N 10
- using namespace std;
- string move;
- char b[N][N];
- void init() {
- for (int i = 1; i < 9; i++)
- for (int j = 1; j < 9; j++)
- b[i][j] = '.';
- for (int i = 1; i < 9; i++)
- b[i][2] = 'P', b[i][7] = 'p';
- b[1][1] = b[8][1] = 'R';
- b[2][1] = b[7][1] = 'N';
- b[3][1] = b[6][1] = 'B';
- b[4][1] = 'Q';
- b[5][1] = 'K';
- for (int i = 1; i < 9; i++)
- b[i][8] = b[i][1] - 'A' + 'a';
- }
- int main() {
- freopen("chess.in", "r", stdin);
- freopen("chess.out", "w", stdout);
- int n;
- cin >> n;
- init();
- for (int i = 0; i < n; i++) {
- cin >> move;
- int l = move.size();
- if (l == 3) {
- if (i % 2) {
- b[7][8] = 'k';
- b[6][8] = 'r';
- b[5][8] = b[8][8] = '.';
- }
- else {
- b[7][1] = 'K';
- b[6][1] = 'R';
- b[5][1] = b[8][1] = '.';
- }
- continue;
- }
- if (l == 5) {
- if (i % 2) {
- b[3][8] = 'k';
- b[4][8] = 'r';
- b[1][8] = b[5][8] = '.';
- }
- else {
- b[3][1] = 'K';
- b[4][1] = 'R';
- b[1][1] = b[5][1] = '.';
- }
- continue;
- }
- char turn = 0, piece;
- if (l == 7)
- turn = move[6];
- int x = move[1] - 'a' + 1, y = move[2] - '0';
- piece = b[x][y];
- b[x][y] = '.';
- x = move[4] - 'a' + 1, y = move[5] - '0';
- b[x][y] = piece;
- if (turn) b[x][y] = turn;
- }
- for (int i = 8; i > 0; i--, cout << endl)
- for (int j = 1; j < 9; j++)
- cout << b[j][i];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement