#include #include #include using namespace std; char arr[8][8] = { { '.', ':', '.', ':', '.', ':', '.', ':'}, { ':', '.', ':', '.', ':', '.', ':', '.'}, { '.', ':', '.', ':', '.', ':', '.', ':'}, { ':', '.', ':', '.', ':', '.', ':', '.'}, { '.', ':', '.', ':', '.', ':', '.', ':'}, { ':', '.', ':', '.', ':', '.', ':', '.'}, { '.', ':', '.', ':', '.', ':', '.', ':'}, { ':', '.', ':', '.', ':', '.', ':', '.'}}; bool bwhite; string line = "+---+---+---+---+---+---+---+---+"; void printRes() { bool wh = true; cout << line << endl; for (int r = 0; r < 8; r++) { cout << "|"; for (int c = 0; c < 8; c++) { cout << ((wh) ? "." : ":"); cout << arr[r][c]; cout << ((wh) ? "." : ":"); cout << "|"; wh = !wh; } wh = !wh; cout << endl; cout << line << endl; } } void addFig(string s) { char t = (s.length() == 2) ? t = 'P' : s[0]; char c = (s.length() == 2) ? s[0] : s[1]; int _c = c - 'a'; char r = (s.length() == 2) ? s[1] : s[2]; int _r = 7 - (r - '1'); arr[_r][_c] = (bwhite) ? (char) toupper(t) : (char) tolower(t); } void readLine() { char ch; // ignore first 7 character cin.get(); cin.get(); cin.get(); cin.get(); cin.get(); cin.get(); cin.get(); while (true) { string s; s += cin.get(); s += cin.get(); ch = cin.get(); if (ch == ',' || ch == '\n' || ch == EOF) { addFig(s); if (ch == '\n' || ch == EOF) { return; } } else { s += ch; addFig(s); ch = cin.get(); if (ch == '\n' || ch == EOF) { return; } } } } int main() { bwhite = true; readLine(); bwhite = false; readLine(); printRes(); return 0; }