#include enum type{ KING, QUEEN, ROOK, BISHOP, KNIGHT, PAWN }; typedef char board[33][17]; board b; char* parseFig(bool black, char *str, board *b) { char t = *str; switch (*str) { case 'K': case 'Q': case 'R': case 'B': case 'N': // printf("not pawn\n"); break; default: t = 'P'; // printf("pawn\n"); str--; } str++; int col = (*str) - 'a'; str++; int row = (*str) - '1'; str++; if (black) t = t - 'A' + 'a'; (*b)[2+4*col][1+2*(7-row)] = t; return str; } void initBoard(board *b) { for (int i=0; i<33; i++) { for (int j=0; j<17; j++) { if (j%2 == 0) { if (i%4 == 0) { (*b)[i][j] = '+'; } else { (*b)[i][j] = '-'; } } else { if (i%4 == 0) { (*b)[i][j] = '|'; } else { if ((i/4 + j/2) % 2 == 0) { (*b)[i][j] = '.'; } else { (*b)[i][j] = ':'; } } } } } } void printBoard(board *b) { for (int j=0; j<17; j++) { for (int i=0; i<33; i++) { printf("%c",(*b)[i][j]); } printf("\n"); } } int main() { char a[1000]; initBoard(&b); gets(a); bool black; if (a[0] == 'W') black = false; else black = true; char *tmp = a+7; while (*tmp != NULL) { tmp = parseFig(black,tmp,&b); if (*tmp == ',') tmp++; } gets(a); if (a[0] == 'W') black = false; else black = true; tmp = a+7; while (*tmp != NULL) { tmp = parseFig(black,tmp,&b); if (*tmp == ',') tmp++; } printBoard(&b); return 0; }