简单模拟
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
const int maxn=101;
char a[maxn][maxn];
char match[10]={0,'K','Q','R','B','N','P'};
int main()
{
//
freopen("in.txt","r",stdin);
int t=0;
while(1)
{
if(scanf("%s",&a[++t][1])==EOF)
break;
}
t--;
int s=strlen(&a[1][1]);
int lon=0;
printf("White: ");
for(int k=1;k<=6;k++)
for(int i=t-1;i>=1;i-=2)
for(int j=3,c=0;j<=s;j+=4,c++)
if(a[i][j]==match[k])
{
if(++lon!=1) printf(",");
if(match[k]!='P')
printf("%c",match[k]);
printf("%c",'a'+c);
printf("%d",8-i/2+1);
}
lon=0;
printf("\nBlack: ");
for(int k=1;k<=6;k++)
for(int i=2;i<=t-1;i+=2)
for(int j=3,c=0;j<=s;j+=4,c++)
if(a[i][j]+'A'-'a'==match[k])
{
if(++lon!=1) printf(",");
if(match[k]!='P')
printf("%c",match[k]);
printf("%c",'a'+c);
printf("%d",8-i/2+1);
}
return 0;
}