#include #include typedef char board[8][8]; char *find(board &poile,char f,char *out) { for (int j=0; j<8; j++) { for (int i=0; i<8; i++) { if (poile[i][j] == f) { char c = f - 'a' + 'A'; if (c!='P') *out++ = c; *out++ = i + 'a'; *out++ = (7-j) + '1'; *out++ = ','; } } } return out; } char *find_white(board &poile,char f,char *out) { for (int j=7; j>=0; j--) { for (int i=0; i<8; i++) { if (poile[i][j] == f) { if (f!='P') *out++ = f; *out++ = i + 'a'; *out++ = (7-j) + '1'; *out++ = ','; } } } return out; } int main(void) { char a[1000]; char poile[8][8]; for (int i=0; i<8; i++) { gets(a); gets(a); for (int j=0; j<8; j++) { poile[j][i] = a[(j*4)+2]; // printf("%c",poile[j][i]); } // printf("\n"); } char out[1000]; memset(out,0,1000); char *tmp = out; tmp = find_white(poile,'K',tmp); tmp = find_white(poile,'Q',tmp); tmp = find_white(poile,'R',tmp); tmp = find_white(poile,'B',tmp); tmp = find_white(poile,'N',tmp); tmp = find_white(poile,'P',tmp); *(--tmp) = 0; printf("White: %s\n",out); tmp = out; memset(out,0,1000); tmp = find(poile,'k',tmp); tmp = find(poile,'q',tmp); tmp = find(poile,'r',tmp); tmp = find(poile,'b',tmp); tmp = find(poile,'n',tmp); tmp = find(poile,'p',tmp); *(--tmp) = 0; printf("Black: %s\n",out); }