#include #include #include #include static void read(char (*board)[8], int upcase) { char buf[BUFSIZ], *p; gets (buf); for (p = buf; *p == ' ' || *p == '\t'; p++) ; while (*p != 0) { char t; if (isupper ((unsigned char)*p)) t = *p++; else t = 'P'; board[7 - (p[1] - '1')][(*p - 'a')] = upcase ? t : tolower (t); p += 2; if (*p == ',') p++; } } int main (void) { static const char line[] = "+---+---+---+---+---+---+---+---+"; char board[8][8]; size_t i; memset (board, 0, sizeof (board)); scanf (" White:"); read (board, 1); scanf (" Black:"); read (board, 0); puts (line); for (i = 0; i < 8; i++) { size_t j; putchar ('|'); for (j = 0; j < 8; j++) { char d; d = (i + j) % 2 == 0 ? '.' : ':'; putchar (d); putchar (board[i][j] != 0 ? board[i][j] : d); putchar (d); putchar ('|'); } putchar ('\n'); puts (line); } return EXIT_SUCCESS; }