1.Link:

http://poj.org/problem?id=2996

2.Content:

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

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

3.Method:

模拟题,输入输出麻烦,最好一部部增加格式,来调整,不然一开始考虑全部的话很容易混乱

4.Code:

 #include <iostream>
#include <string>
#include <cstring> using namespace std; struct Point_c
{
char name;
char p_ch;
char p_num;
}; const char name_c[] = {'K','Q','R','R','B','B','N','N','P','P','P','P','P','P','P','P',
'k','q','r','r','b','b','n','n','p','p','p','p','p','p','p','p'};
const int num_c = ; int main()
{
//freopen("D://input.txt","r",stdin); int i,j,k;
char p_ch[num_c];
char p_num[num_c]; //cout << str << endl;
memset(p_ch,,sizeof(char) * num_c);
memset(p_num,,sizeof(char) * num_c); string *arr_str = new string[];
string str;
for(i = ; i < ; ++i)
{
cin >> str;
cin >> arr_str[i];
}
cin >> str; //for(i = 0; i < 8; ++i) cout << arr_str[i] << endl; for(i = ; i >= ; --i)
{
for(j = ; j < ; ++j)
{
for(k = ; k < ; ++k)
{
if(name_c[k] == arr_str[i][ + * j] && p_ch[k] == )
{
p_ch[k] = j + 'a';
p_num[k] = ( - i) + '';
break;
}
}
}
} for(i = ; i < ; ++i)
{
for(j = ; j < ; ++j)
{
for(k = ; k < ; ++k)
{
if(name_c[k] == arr_str[i][ + * j] && p_ch[k] == )
{
p_ch[k] = j + 'a';
p_num[k] = ( - i) + '';
break;
}
}
}
} int flag = ; cout << "White: ";
for(k = ; k < ; ++k) if(p_ch[k] != )
{
if(p_ch[k] != )
{
if(flag) cout << ",";
else flag = ;
cout << name_c[k] << p_ch[k] << p_num[k];
}
}
for(k = ; k < ; ++k)
{
if(p_ch[k] != )
{
if(flag) cout << ",";
else flag = ;
cout << p_ch[k] << p_num[k];
} }
cout << endl; flag = ;
cout << "Black: ";
for(k = ; k < ; ++k) if(p_ch[k] != )
{
if(p_ch[k] != )
{
if(flag) cout << ",";
else flag = ;
cout << (char)(name_c[k] + ('K' - 'k')) << p_ch[k] << p_num[k];
} }
for(k = ; k < ; ++k)
{
if(p_ch[k] != )
{
if(flag) cout << ",";
else flag = ;
cout << p_ch[k] << p_num[k];
}
}
cout << endl; delete [] arr_str; return ;
}

5.Reference:

Poj 2996 Help Me with the Game的更多相关文章

  1. 模拟 POJ 2996 Help Me with the Game

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

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

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

  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 棋盘 模拟 暴力 难度:0

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

  5. poj 2996

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

  6. POJ 2996:Help Me with the Game

    Help Me with the Game Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64 ...

  7. poj很好很有层次感(转)

    OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 30 ...

  8. POJ题目分类推荐 (很好很有层次感)

    著名题单,最初来源不详.直接来源:http://blog.csdn.net/a1dark/article/details/11714009 OJ上的一些水题(可用来练手和增加自信) (POJ 3299 ...

  9. poj 2993

    跟poj 2996反过来了,这里比较麻烦的就是处理白棋和黑棋各棋子对应的位置 还有在最后打印棋盘式|,:,.的时候会有点繁琐(- - ACMer新手 ): 直接看代码吧: #include<cs ...

随机推荐

  1. 【原创】测试不同浏览器播放canvas动画的平滑程度

    Canvas无疑是HTML5开放式网络平台最激动人心的技术之一.目前,除了IE8以外,各类浏览器的新版本都支持HTML5 Canvas. 程序员需要通过Javascript调用Canvas API.基 ...

  2. decide your linux OS is GUI or not

    Try:  ps -ef|grep X  The ps command will display information about a selection of the active process ...

  3. Oracle学习(七):集合运算

    1.知识点:能够对比以下的录屏进行阅读 SQL> -- 查询10和20号部门的员工的3种方法 SQL> --1. select * from emp where deptno in (10 ...

  4. Swift3.0相对于2.3语法的一些变化

    前言 : Swift3.0的Swift的第3个主要版本,目标是安全,快速和有表现力,也是第一个有开源社区参与开发的Swift版本.由于语法和API改动比较多,Xcode 8.0 Beta提供了migr ...

  5. currentTarget 与 Target 的区别

    在一般情况下,target与currentTarget指向的是同一个对象.一般情况是指我们只对某一个独立的mc添加侦听器.如下: var mc:Sprite=new Sprite();addChild ...

  6. MyISAM表锁

    MyISAM存储引擎只支持表锁,这也是MySQL开始几个版本中唯一支持的锁类型.随着应用对事务完整性和并发性 要求的不断提高,MySQL才开始开发基于事务的存储引擎,后来慢慢出现了支持页锁的BDB存储 ...

  7. if条件

    -e filename 如果 filename存在,则为真-d filename 如果 filename为目录,则为真 -f filename 如果 filename为常规文件,则为真-L filen ...

  8. C#获取CPU等硬件ID(转载)

    System.Management命名空间提供对大量管理信息和管理事件集合的访问,这些信息和事件是与根据 Windows 管理规范 (WMI) 结构对系统.设备和应用程序设置检测点有关的.应用程序和服 ...

  9. [改善Java代码] 枚举项数量限定为64个以内

    建议89:枚举项的数量限制在64个以内 为了更好的使用枚举,java 提供了两个枚举集合:EnumSet和EnumMap,这两个集合的使用都比较简单,EnumSet表示其元素必须是某一枚举的枚举项,E ...

  10. 转:Nginx RTMP 功能研究

    看点: 1.    Nginx 配置信息与使用.  (支持 rtmp与HLS配置) 2.    有ffmpeg 编译与使用,    命令行方式来测试验证客户端使用. 转自:http://blog.cs ...