模拟..wa了一次..因为用文件做的..忘了去掉文件了..
而且一开始看错了题...
导致最后改的时候代码乱七八糟的..orz..
#include <iostream>
using namespace std;
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
char pie_1[6]=
{'K','Q','R','B','N','P'};
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
char pie_2[15]=
{'k','q','r','b','n','p'};
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
bool hash[18][34];
char ch[18][34];
int main()
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif)
{
for (int i=1;i<=17;i++)
for (int j=1;j<=33;j++)
cin>>ch[i][j];
cout<<"White: ";
//find White piece
bool first=false;
memset(hash,0,sizeof(hash));
for (int k=0;k<6;)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
bool is=false;
for (int i=17;i>=1&&(!is);i--)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
for (int j=1;j<=33&&(!is);j++)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (hash[i][j]) continue;
if (ch[i][j]==pie_1[k])
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
hash[i][j]=true;
is=true;
if (!first)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{cout<<pie_1[k]<<(char)(j/4+1+96)<<8-i/2+1;first=true;}
else
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (k>4) cout<<","<<(char)(j/4+1+96)<<8-i/2+1;
else
cout<<","<<pie_1[k]<<(char)(j/4+1+96)<<8-i/2+1;
}
}
}
}
if (!is) k++;
}
cout<<endl;
first=false;
cout<<"Black: ";
memset(hash,0,sizeof(hash));
for (int k=0;k<6;)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
bool is=false;
for (int i=1;i<=17&&(!is);i++)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
for (int j=1;j<=33&&(!is);j++)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (hash[i][j]) continue;
if (ch[i][j]==pie_2[k])
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
hash[i][j]=true;
is=true;
if (k==0)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ cout<<pie_1[k]<<(char)(j/4+1+96)<<8-i/2+1;first=true;}
else
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (k>4) cout<<","<<(char)(j/4+1+96)<<8-i/2+1;
else
cout<<","<<pie_1[k]<<(char)(j/4+1+96)<<8-i/2+1;
}
}
}
}
if (!is) k++;
}
cout<<endl;
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
return 0;
}
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)