| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 3344 | Accepted: 2145 |
Description
Input
Output
Sample Input
+---+---+---+---+---+---+---+---+ |.r.|:::|.b.|:q:|.k.|:::|.n.|:r:| +---+---+---+---+---+---+---+---+ |:p:|.p.|:p:|.p.|:p:|.p.|:::|.p.| +---+---+---+---+---+---+---+---+ |...|:::|.n.|:::|...|:::|...|:p:| +---+---+---+---+---+---+---+---+ |:::|...|:::|...|:::|...|:::|...| +---+---+---+---+---+---+---+---+ |...|:::|...|:::|.P.|:::|...|:::| +---+---+---+---+---+---+---+---+ |:P:|...|:::|...|:::|...|:::|...| +---+---+---+---+---+---+---+---+ |.P.|:::|.P.|:P:|...|:P:|.P.|:P:| +---+---+---+---+---+---+---+---+ |:R:|.N.|:B:|.Q.|:K:|.B.|:::|.R.| +---+---+---+---+---+---+---+---+
Sample Output
White: Ke1,Qd1,Ra1,Rh1,Bc1,Bf1,Nb1,a2,c2,d2,f2,g2,h2,a3,e4 Black: Ke8,Qd8,Ra8,Rh8,Bc8,Ng8,Nc6,a7,b7,c7,d7,e7,f7,h7,h6
#include<iostream>
using namespace std;
#define WHILT 1
#define BLACK 0
char str[10][10],ch[]="KQRBNP";
void hansi(int x,int &y,char c)
{
char c1=c;
int i,j;
if(x==BLACK)
c += 32;
if(x==BLACK)
{
for(i=1;i<=8;i++)
{
for(j=1;j<=8;j++)
{
if(str[i][j]==c)
{
if(y) y=0;
else cout<<",";
if(c!='p' && c!='P')
cout<<c1;
printf("%c%d",j+'a'-1,9-i);
}
}
}
}
else
{
for(i=8;i>=1;i--)
{
for(j=1;j<=8;j++)
{
if(str[i][j]==c)
{
if(y) y=0;
else cout<<",";
if(c!='p' && c!='P')
cout<<c1;
printf("%c%d",j+'a'-1,9-i);
}
}
}
}
}
void hanyi()
{
scanf("+---+---+---+---+---+---+---+---+");
getchar();
}
char haner()
{
char a,b,c;
scanf("|%c%c%c",&a,&b,&c);
return b;
}
void hansan(int cur)
{
if(cur==WHILT)
cout<<"White: ";
else
cout<<"Black: ";
int flag=1;
for(int i=0;i<6;i++)
hansi(cur,flag,ch[i]);
cout<<endl;
}
int main()
{
int i,j;
for(i=1;i<=8;i++)
{
hanyi();
for(j=1;j<=8;j++)
str[i][j]=haner();
getchar();
getchar();
}
hanyi();
hansan(WHILT);
hansan(BLACK);
return 0;
}POJ 2996 Help Me with the Game 模拟
原文地址:http://blog.csdn.net/hyccfy/article/details/38025909