#include #include #include using namespace std; #define printx #ifdef printx #define o(a) cout << #a << ": " << a << endl #else #define o(a) #endif #define M 10 struct fig { int x, y; }; //K, Q, R, B, N, P (0-5) int main(void) { fig figw[6][M]; fig figb[6][M]; int posw[6]; int posb[6]; char aux[2]; char board[9][9]; int i, j; stringstream ss; string s; for(i = 0; i < 6; i++) { posw[i] = 0; posb[i] = 0; } for(i = 8; i > 0; i--) { cin >> s; cin >> s; for(j = 30; j > 0; j -= 4) { board[i][(j + 2) >> 2] = s[j]; switch(s[j]) { case 'K': figw[0][posw[0]].x = i; figw[0][posw[0]++].y = (j + 2) >> 2; break; case 'Q': figw[1][posw[1]].x = i; figw[1][posw[1]++].y = (j + 2) >> 2; break; case 'R': figw[2][posw[2]].x = i; figw[2][posw[2]++].y = (j + 2) >> 2; break; case 'B': figw[3][posw[3]].x = i; figw[3][posw[3]++].y = (j + 2) >> 2; break; case 'N': figw[4][posw[4]].x = i; figw[4][posw[4]++].y = (j + 2) >> 2; break; case 'P': figw[5][posw[5]].x = i; figw[5][posw[5]++].y = (j + 2) >> 2; break; default: break; } } } /* for(i = 0; i < 6; i++) { cout << i << ": "; j = posw[i]; while(--j >= 0) { cout << "(" << figw[i][j].y << "," << figw[i][j].x << ")"; } cout << endl; } return 0; */ for(j = 8; j > 0; j--) { for(i = 0; i < 9; i++) { switch(board[i][j]) { case 'k': figb[0][posb[0]].x = i; figb[0][posb[0]++].y = j; break; case 'q': figb[1][posb[1]].x = i; figb[1][posb[1]++].y = j; break; case 'r': figb[2][posb[2]].x = i; figb[2][posb[2]++].y = j; break; case 'b': figb[3][posb[3]].x = i; figb[3][posb[3]++].y = j; break; case 'n': figb[4][posb[4]].x = i; figb[4][posb[4]++].y = j; break; case 'p': figb[5][posb[5]].x = i; figb[5][posb[5]++].y = j; break; } } } ss << "White: "; for(i = 0; i < 6; i++) { if(posw[i] != 0) { while(--posw[i] >= 0) { switch(i) { case 0: ss << 'K'; break; case 1: ss << 'Q'; break; case 2: ss << 'R'; break; case 3: ss << 'B'; break; case 4: ss << 'N'; break; case 5: break; } aux[0] = (figw[i][posw[i]].y - 1) + 'a'; aux[1] = '\0'; ss << string(aux); aux[0] = (figw[i][posw[i]].x) + '0'; ss << string(aux); ss << ","; } } } cout << ss.str().substr(0, ss.str().length() - 1); cout << endl; { stringstream ss; ss << "Black: "; for(i = 0; i < 6; i++) { if(posb[i] != 0) { while(--posb[i] >= 0) { switch(i) { case 0: ss << 'K'; break; case 1: ss << 'Q'; break; case 2: ss << 'R'; break; case 3: ss << 'B'; break; case 4: ss << 'N'; break; case 5: break; } aux[0] = figb[i][posb[i]].y - 1 + 'a'; aux[1] = '\0'; ss << string(aux); aux[0] = figb[i][posb[i]].x + '0'; ss << string(aux); ss << ","; } } } cout << ss.str().substr(0, ss.str().length() - 1); cout << endl; } return 0; }