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

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.

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

Source

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
char map[10][10];
char str[10]="KQRBNP";
void pri(int i,char c,int &first){
if(i==1){
for(int i=8;i>=1;i--){
for(int j=1;j<=8;j++){
if(map[i][j]==c){
if(!first)
first=1;
else
printf(",");
if(c!='P')
printf("%c",c);
printf("%c%d",'a'+j-1,9-i);
}
}
}
}
else if(i==0){
for(int i=1;i<=8;i++){
for(int j=1;j<=8;j++){
if(map[i][j]==c+32){
if(!first)
first=1;
else
printf(",");
if(c!='P')
printf("%c",c);
printf("%c%d",'a'+j-1,9-i);
}
}
}
}
}
void getanswer(int i){
if(i==1)
printf("White: ");
else if(i==0)
printf("Black: ");
int first=0;
for(int k=0;k<=5;k++){
pri(i,str[k],first);
}
}
void getline(){
scanf("+---+---+---+---+---+---+---+---+") ;
getchar();
}
char getcase(){
char a,b,c;
scanf("|%c%c%c",&a,&b,&c);
return b ;
}
int main(){

for(int i=1;i<=8;i++){
getline();
for(int j=1;j<=8;j++){
char temp=getcase();
map[i][j]=temp;
}
getchar();
getchar();
}
getline();
getanswer(1);
cout<<endl;
getanswer(0);

cout<<endl;

return 0;
}

poj2996 模拟的更多相关文章

  1. POJ2996 Help Me with the Game(模拟)

    题目链接. 分析: 简单模拟. #include <iostream> #include <queue> #include <cstdio> #include &l ...

  2. 模拟 POJ 2993 Emag eht htiw Em Pleh

    题目地址:http://poj.org/problem?id=2993 /* 题意:与POJ2996完全相反 模拟题 + 字符串处理:无算法,读入两行字符串找出相应点用used标记,输出时标记过的输出 ...

  3. POJ 2996 &amp; 2993 国际象棋布局 模拟

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

  4. POJ-2996 Help Me with the Game---模拟棋子

    题目链接: https://vjudge.net/problem/POJ-2996 题目大意: 给出白方和黑方的棋子和对应的坐标,输出该副棋盘的样子 1,棋盘中大写字母表示的是白方棋子,小写是黑方.2 ...

  5. App开发:模拟服务器数据接口 - MockApi

    为了方便app开发过程中,不受服务器接口的限制,便于客户端功能的快速测试,可以在客户端实现一个模拟服务器数据接口的MockApi模块.本篇文章就尝试为使用gradle的android项目设计实现Moc ...

  6. 故障重现, JAVA进程内存不够时突然挂掉模拟

    背景,服务器上的一个JAVA服务进程突然挂掉,查看产生了崩溃日志,如下: # Set larger code cache with -XX:ReservedCodeCacheSize= # This ...

  7. Python 爬虫模拟登陆知乎

    在之前写过一篇使用python爬虫爬取电影天堂资源的博客,重点是如何解析页面和提高爬虫的效率.由于电影天堂上的资源获取权限是所有人都一样的,所以不需要进行登录验证操作,写完那篇文章后又花了些时间研究了 ...

  8. HTML 事件(四) 模拟事件操作

    本篇主要介绍HTML DOM中事件的模拟操作. 其他事件文章 1. HTML 事件(一) 事件的介绍 2. HTML 事件(二) 事件的注册与注销 3. HTML 事件(三) 事件流与事件委托 4.  ...

  9. 模拟AngularJS之依赖注入

    一.概述 AngularJS有一经典之处就是依赖注入,对于什么是依赖注入,熟悉spring的同学应该都非常了解了,但,对于前端而言,还是比较新颖的. 依赖注入,简而言之,就是解除硬编码,达到解偶的目的 ...

随机推荐

  1. java ee 中文乱码的问题

    java ee 中文乱码的问题 发生中文乱码的三种情况 (一) 表单form Post 方法 直接在服务器中设置 request.setCharacterEncoding("utf-8&qu ...

  2. poj3692 最大点权独立集/最大独立集

    题意:有男孩和女孩,男孩之间全部认识,女孩之间全部认识,一部分男孩和女孩认识,现在希望选出一些孩子,这些孩子都相互认识. 方法:正的做不好做,观察他的补图,补图之间无关系的边就是原图有关系的.补图中的 ...

  3. Day1 三级目录

    d_city = { "河南" : {"郑州" : ["二七区","中原区","回族管城区",&qu ...

  4. 修改Oracle权限的SQL及常见错误

    1.在cmd命令中进入sqlplus:相应的在DOS命令下执行:(1)set ORACLE_SID = $INSTANCE_NAME(2)sqlplus /nolog(3)connect user/p ...

  5. 39.Android版本小知识

    中文名----英文名----版本----对应API Level 棉花糖 Marshmallow - 6.0.1_r10 - API 23棉花糖 Marshmallow - 6.0.0_r5 - API ...

  6. BZOJ-4010 菜肴制作 贪心+堆+(拓扑图拓扑序)

    无意做到...char哥还中途强势插入干我...然后据他所言,看了一会题,一转头,我爆了正解....可怕 4010: [HNOI2015]菜肴制作 Time Limit: 5 Sec Memory L ...

  7. BZOJ3098 Hash Killer II

    Description 这天天气不错,hzhwcmhf神犇给VFleaKing出了一道题: 给你一个长度为N的字符串S,求有多少个不同的长度为L的子串. 子串的定义是S[l].S[l + 1].... ...

  8. 以一个权限系统来告别WebForm —开篇

     前言: 当今是互联网的时代,我们己经阻止不了它的发展了,只有跟上脚步,才不会被抛弃,松散了这么久,该紧紧了.  背景: 我之所以说以一个权限应用系统来告别我的WebForm内部系统的生涯,是缘于我自 ...

  9. Redis Installation、Configuration、Program Based On Redis Learning

    目录 . Redis 简介 . Redis安装配置 . 编程使用Redis . 使用Lua脚本 1. Redis 简介 0x1: Redis是什么 Redis是一款Nosql类型的基于key-valu ...

  10. ubuntu 14.04 vim install youcompleteme

    sudo apt-get install vim ; sudo apt-get install vim-youcompleteme ; sudo apt-get install vim-addon-m ...