Description

Your task is to read a picture of a chessboard position and print it in the chess notation.

Input

The input consists of an ASCII-art picture of a chessboard with chess pieces on positions described by the input. The pieces of the white player are shown in upper-case letters, while the black player's pieces are lower-case letters.
The letters are one of "K" (King), "Q" (Queen), "R" (Rook), "B" (Bishop), "N" (Knight), or "P" (Pawn). The chessboard outline is made of plus ("+"), minus ("-"), and pipe ("|") characters. The black fields are filled with colons (":"), white fields with dots
(".").

Output

The output consists of two lines. The first line consists of the string "White: ", followed by the description of positions of the pieces of the white player. The second line consists of the string "Black: ", followed by the description
of positions of the pieces of the black player.



The description of the position of the pieces is a comma-separated list of terms describing the pieces of the appropriate player. The description of a piece consists of a single upper-case letter that denotes the type of the piece (except for pawns, for that
this identifier is omitted). This letter is immediatelly followed by the position of the piece in the standard chess notation -- a lower-case letter between "a" and "h" that determines the column ("a" is the leftmost column in the input) and a single digit
between 1 and 8 that determines the row (8 is the first row in the input).



The pieces in the description must appear in the following order: King("K"), Queens ("Q"), Rooks ("R"), Bishops ("B"), Knights ("N"), and pawns. Note that the numbers of pieces may differ from the initial position because of capturing the pieces and the promotions
of pawns. In case two pieces of the same type appear in the input, the piece with the smaller row number must be described before the other one if the pieces are white, and the one with the larger row number must be described first if the pieces are black.
If two pieces of the same type appear in the same row, the one with the smaller column letter must appear first.

poj2993:

Sample Input

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

Sample Output

+---+---+---+---+---+---+---+---+
|.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.|
+---+---+---+---+---+---+---+---+

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char q[10],w[100];
char e[10],r[100];
char white[12]= {'K','Q','R','B','N','P'};
char black[12]= {'k','q','r','b','n','p'};
char map1[18][35];
int s1,s2;
int main()
{
int i,j;
for(i=1; i<=17; i++) //初始化地图
for(j=1; j<=33; j++)
{
if(i%2==1&&j%4==1)
map1[i][j]='+';
else if(i%2==1)
map1[i][j]='-';
else if(i%2==0&&j%4==1)
map1[i][j]='|';
else if(i%4==2&&(double)(j%8)/4<=1&&j%8!=0)
map1[i][j]='.';
else if(i%4==0&&((double)(j%8)/4>1||j%8==0))
map1[i][j]='.';
else
map1[i][j]=':';
}
for(int k=1; k<=2; k++) //两行输入
{
scanf("%s%s",q,w);
s1=strlen(w);
if(q[0]=='W')
{
for(i=0; i<=5; i++)
for(j=0; j<=s1; j++)
{
if(w[j]==white[i])
map1[2*(9-w[j+2]+'0')][4*(w[j+1]-'a')+3]=white[i];
if(w[j]==','&&w[j+1]>96)
map1[2*(9-w[j+2]+'0')][4*(w[j+1]-'a')+3]='P';
}
}
if(q[0]=='B')
{
for(i=0; i<=5; i++)
for(j=0; j<=s1; j++)
{
if(w[j]==white[i])
map1[2*(9-w[j+2]+'0')][4*(w[j+1]-'a')+3]=black[i];
if(w[j]==','&&w[j+1]>96)
map1[2*(9-w[j+2]+'0')][4*(w[j+1]-'a')+3]='p';
}
}
}
for(i=1; i<=17; i++)
{
for(j=1; j<=33; j++)
cout<<map1[i][j];
cout<<endl;
}
return 0;
}

poj2996:

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>
#include<cstdio>
using namespace std;
char black[6]= {'K','Q','R','B','N','P'};
char white[6]= {'k','q','r','b','n','p'};
int main()
{
int s1,s2;
int i,j,k;
char map1[18][34];
s1=s2=0;
for(i=1; i<=17; i++)
for(j=1; j<=33; j++)
{
cin>>map1[i][j];
if(map1[i][j]=='p') //这个是为了不输出最后的那个逗号。。 。
s1++;
if(map1[i][j]=='P')
s2++;
}
cout<<"White: ";
for(k=0; k<6; k++)
for(i=17; i>=1; i--)
for(j=1; j<=33; j++)
{
if(i%2==0&&j%4==3&&k<=4)
if(map1[i][j]==black[k])
{
printf("%c%c%d,",black[k],'a'+(j+1)/4-1,9-i/2);
}
if(k==5&&i%2==0&&j%4==3)
if(map1[i][j]=='P')
{
s1--;
if(s1==0)
{
printf("%c%d\n",'a'+(j+1)/4-1,9-i/2);
continue;
}
printf("%c%d,",'a'+(j+1)/4-1,9-i/2);
}
}
cout<<"Black: ";
for(k=0; k<6; k++)
for(i=1; i<=17; i++)
for(j=1; j<=33; j++)
{
if(i%2==0&&j%4==3&&k<=4)
if(map1[i][j]==white[k])
{
printf("%c%c%d,",black[k],'a'+(j+1)/4-1,9-i/2);
}
if(k==5&&i%2==0&&j%4==3)
if(map1[i][j]=='p')
{
s2--;
if(s2==0)
{
printf("%c%d\n",'a'+(j+1)/4-1,9-i/2);
continue;
}
printf("%c%d,",'a'+(j+1)/4-1,9-i/2);
}
}
return 0;
}

基本渣 这样的模拟题只能用时间来堆TAT

POJ 2996 &amp; 2993 国际象棋布局 模拟的更多相关文章

  1. 模拟 POJ 2996 Help Me with the Game

    题目地址:http://poj.org/problem?id=2996 /* 题意:给出白方和黑方的棋子和对应的坐标,输出该副棋盘的样子 模拟题 + 结构体排序:无算法,switch区分读入的字符,按 ...

  2. POJ.3087 Shuffle'm Up (模拟)

    POJ.3087 Shuffle'm Up (模拟) 题意分析 给定两个长度为len的字符串s1和s2, 接着给出一个长度为len*2的字符串s12. 将字符串s1和s2通过一定的变换变成s12,找到 ...

  3. poj 2996

    提示:很烦很简单的国际象棋棋盘模拟,输入比较麻烦而已 输出时: 1.不论黑白,KQRBN P均是依次输出,强制大写,但不输出“P”,只输出其坐标 2.对白棋的位置,小行优先大行输出(行的数字越小则优先 ...

  4. poj 2996 Help Me with the Game(模拟)

    题目:http://poj.org/problem?id=2996 题意:给出 棋盘 情况 输出 白棋 和 黑棋在 棋盘上的 白棋为大写字母 黑棋为小写字母 棋盘 左下点为原点(1,a) 输出 是 按 ...

  5. 快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0

    Help Me with the Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3510   Accepted:  ...

  6. Poj 2996 Help Me with the Game

    1.Link: http://poj.org/problem?id=2996 2.Content: Help Me with the Game Time Limit: 1000MS   Memory ...

  7. POJ 1936 All in All(模拟)

    All in All 题目链接:http://poj.org/problem?id=1936 题目大意:判断从字符串s2中能否找到子串s1.字符串长度为10W. Sample Input sequen ...

  8. POJ 3009 Curling 2.0(DFS + 模拟)

    题目链接:http://poj.org/problem?id=3009 题意: 题目很复杂,直接抽象化解释了.给你一个w * h的矩形格子,其中有包含一个数字“2”和一个数字“3”,剩下的格子由“0” ...

  9. Uva 127 poj 1214 `Accordian'' Patience 纸牌游戏 模拟

    Input Input data to the program specifies the order in which cards are dealt from the pack. The inpu ...

随机推荐

  1. Linux 软连接与硬连接

    Linux 软连接与硬连接 对于一个文件来说,有唯一的索引接点与之相应,而对于一个索引接点号,却能够有多个文件名称与之相应.因此,在磁盘上的同一个文件能够通过不同的路径去訪问该文件.注意在Linux下 ...

  2. JDK源码学习系列03----StringBuffer+StringBuilder

                         JDK源码学习系列03----StringBuffer+StringBuilder 由于前面学习了StringBuffer和StringBuilder的父类A ...

  3. 从最大似然到EM算法浅解

    从最大似然到EM算法浅解 zouxy09@qq.com http://blog.csdn.net/zouxy09 机器学习十大算法之中的一个:EM算法.能评得上十大之中的一个,让人听起来认为挺NB的. ...

  4. SQL server 表数据改变触发发送邮件

    今天遇到一个问题,原有生产系统正在健康运行,现需要监控一张数据表,当增加数据的时候,给管理员发送邮件. 领到这个需求后,有同事提供方案:写触发器触发外部应用程序.这是个大胆的想法啊,从来没写过这样的触 ...

  5. Spring+Mybatis+SpringMVC后台与前台分页展示实例(附工程)(转)

    林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:本文实现了一个后台由Spring+Mybatis+SpringMVC组成,分页采用Pag ...

  6. Oracle在不同的语言环境结果to_date错误的问题

    我写了一个存储过程,它使用了功能,有一些功能to_date(dateFrom, 'yyyy/mm/dd').执行发现数据插入错误后,数据插入"0001/9/14". 感觉莫名其妙, ...

  7. 返璞归真 asp.net mvc (5) - Action Filter, UpdateModel, ModelBinder, Ajax, Unit Test

    原文:返璞归真 asp.net mvc (5) - Action Filter, UpdateModel, ModelBinder, Ajax, Unit Test [索引页] [源码下载] 返璞归真 ...

  8. HDU 1874 畅通公程续 (最短路 水)

    Problem Description 某省自从实行了非常多年的畅通project计划后,最终修建了非常多路.只是路多了也不好,每次要从一个城镇到还有一个城镇时,都有很多种道路方案能够选择,而某些方案 ...

  9. synchronized与static synchronized 差异

    1.synchronized与static synchronized 差异       synchronized是对类的当前实例进行加锁,防止其它线程同一时候訪问该类的该实例的全部synchroniz ...

  10. 11gR2 Database Services for &quot;Policy&quot; and &quot;Administrator&quot; Managed Databases (文件 ID 1481647.1)

    In this Document   _afrLoop=1459311711568804&id=1481647.1&displayIndex=6&_afrWindowMode= ...