题目传送门

本题知识点:模拟(如果对国际象棋不熟悉的同学可以先百度一下

本题跟POJ2996是逆过来的操作,如果做过【POJ2996】的同学就不会对题意不理解的了。

(以下默认您已AC【POJ2996】)

个人觉得该题比【POJ2996】要麻烦一点,因为要创建一个棋盘(其实也不是什么麻烦事)

创好棋盘后,再把棋子一个个地放回去就可以了,这步操作跟【POJ2996】有异曲同工之妙

数据很小(快乐水题)

#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
const int H = 17;
const int W = 33;
char chess[40][40];
string white, black;
struct node{
string pla;
}w[20], b[20]; void build(){
for(int i = 1; i <= H; i++){
if(i % 2 == 1){
for(int j = 1; j <= W; j++){
if(j % 4 == 1) chess[i][j] = '+';
else chess[i][j] = '-';
}
}
else if(i % 4 == 2){
for(int j = 1; j <= W; ){
if(j % 4 == 1) {
chess[i][j] = '|';
j += 3;
}
else {
if(j % 8 == 4){
chess[i][j] = chess[i][j - 1] = chess[i][j - 2] = '.';
j++;
}
else {
chess[i][j] = chess[i][j - 1] = chess[i][j - 2] = ':';
j++;
}
}
}
}
else if(i % 2 == 0){
for(int j = 1; j <= W; ){
if(j % 4 == 1) {
chess[i][j] = '|';
j += 3;
}
else {
if(j % 8 == 4){
chess[i][j] = chess[i][j - 1] = chess[i][j - 2] = ':';
j++;
}
else {
chess[i][j] = chess[i][j - 1] = chess[i][j - 2] = '.';
j++;
}
}
}
}
}
} char turn(char x){
if('A' <= x && x <= 'Z')
x += 32;
return x;
} int main()
{
build(); getline(cin, white);
// White
int cnt_w = 0, h, w;
for(int i = 7; i < white.size(); ){
if(white[i] == 'K' || white[i] == 'Q' || white[i] == 'R' || white[i] == 'B' || white[i] == 'N'){
w = (white[i + 1] - 'a') * 4 + 3;
char ch = white[i + 2];
if(ch == '1') h = 16;
else if(ch == '2') h = 14;
else if(ch == '3') h = 12;
else if(ch == '4') h = 10;
else if(ch == '5') h = 8;
else if(ch == '6') h = 6;
else if(ch == '7') h = 4;
else if(ch == '8') h = 2;
chess[h][w] = white[i];
i += 4;
}
else {
w = (white[i] - 'a') * 4 + 3;
char ch = white[i + 1];
if(ch == '1') h = 16;
else if(ch == '2') h = 14;
else if(ch == '3') h = 12;
else if(ch == '4') h = 10;
else if(ch == '5') h = 8;
else if(ch == '6') h = 6;
else if(ch == '7') h = 4;
else if(ch == '8') h = 2;
chess[h][w] = 'P';
i += 3;
}
} getline(cin, black);
// Black
int cnt_b = 0;
for(int i = 7; i < black.size(); ){
if(black[i] == 'K' || black[i] == 'Q' || black[i] == 'R' || black[i] == 'B' || black[i] == 'N'){
w = (black[i + 1] - 'a') * 4 + 3;
char ch = black[i + 2];
if(ch == '1') h = 16;
else if(ch == '2') h = 14;
else if(ch == '3') h = 12;
else if(ch == '4') h = 10;
else if(ch == '5') h = 8;
else if(ch == '6') h = 6;
else if(ch == '7') h = 4;
else if(ch == '8') h = 2;
char b = turn(black[i]);
chess[h][w] = b;
i += 4;
}
else {
w = (black[i] - 'a') * 4 + 3;
char ch = black[i + 1];
if(ch == '1') h = 16;
else if(ch == '2') h = 14;
else if(ch == '3') h = 12;
else if(ch == '4') h = 10;
else if(ch == '5') h = 8;
else if(ch == '6') h = 6;
else if(ch == '7') h = 4;
else if(ch == '8') h = 2;
chess[h][w] = 'p';
i += 3;
}
} for(int i = 1; i <= H; i++) printf("%s\n", chess[i] + 1); return 0;
}

【POJ2993】Emag eht htiw Em Pleh的更多相关文章

  1. POJ 2993 Emag eht htiw Em Pleh【模拟画棋盘】

    链接: http://poj.org/problem?id=2993 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#probl ...

  2. POJ2993——Emag eht htiw Em Pleh(字符串处理+排序)

    Emag eht htiw Em Pleh DescriptionThis problem is a reverse case of the problem 2996. You are given t ...

  3. 模拟 + 打表 --- Emag eht htiw Em Pleh

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2578   Accepted: ...

  4. Emag eht htiw Em Pleh(imitate)

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2901   Accepted:  ...

  5. 模拟 POJ 2993 Emag eht htiw Em Pleh

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

  6. Emag eht htiw Em Pleh 分类: POJ 2015-06-29 18:54 10人阅读 评论(0) 收藏

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2937   Accepted: ...

  7. Poj 2993 Emag eht htiw Em Pleh

    1.Link: http://poj.org/problem?id=2993 2.Content: Emag eht htiw Em Pleh Time Limit: 1000MS   Memory ...

  8. Emag eht htiw Em Pleh

    Emag eht htiw Em Pleh This problem is a reverse case of the problem 2996. You are given the output o ...

  9. 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted:  ...

随机推荐

  1. IDEA自动清理优化import包

    IDEA自动清理优化import包 直接上图: Add unambiguous imports on the fly:快速添加明确的导入. Optimize imports on the fly:快速 ...

  2. vue项目中添加单元测试

    从网上找了很多例子关于单元测试,都是如何新建项目的时候的添加单元测试,用vue-cli中怎么添加,但是我的项目已经生成了,不能再一次重新初始化,这时如何添加单元测试,这里面遇到了好多坑,写在这里记录一 ...

  3. jsonpath_rw操作json

    from jsonpath_rw import parse def get_key_from_data(key,data): # 定义匹配规则 json_expr=parse(key) result= ...

  4. Oracle 用户与模式的关系

    一.用户登录 Oracle 数据库的安全保护流程分为3个步骤. 1.用户向数据库提供身份识别信息,即提供一个数据库账号 2.证明身份识别信息是否有效,通过密码来实现 3.用户输入的密码经过数据库的核对 ...

  5. chattr和lsattr命令

    原文 在一个技术群上看到这么一个问题: 问题出现在服务器被黑后!特意出记录下问题的解决方法. 由于被黑了,所以我们的很多命令将会出现使用不正常等问题,而这些问题大多是给人家添加或删除了某些权限所致.比 ...

  6. rancheros在vm主机部署

    问题描述: 容器化,越来越重要.在云服务中很大比例的服务都跑在容器中,今天介绍rancheros基于容器的os. 特点: 启动快,比较小系统服务也是基于容器化 使用最新的docker release ...

  7. Yii2模型介绍

    通过来说,我们可以把yii2中的Mdoel分为两种: 1)数据模型: 2)表单模型: 数据模型 数据模型关联数据表,用来实现对数据的操作; 一般数据模型放在common/models下: 表单模型 表 ...

  8. linux设备驱动程序--串行通信驱动框架分析

    linux 串行通信接口驱动框架 在学习linux内核驱动时,不论是看linux相关的书籍,又或者是直接看linux的源码,总是能在linux中看到各种各样的框架,linux内核极其庞杂,linux各 ...

  9. Linux操作系统启动故障排错之"/sbin/init"文件被删除恢复案例

    Linux操作系统启动故障排错之"/sbin/init"文件被删除恢复案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.删除"/sbin/ini ...

  10. 用PHP的fopen函数读写robots.txt文件

    以前介绍了用PHP读写文本文档制作最简单的访问计数器不需要数据库,仅仅用文本文档就可以实现网页访问计数功能.同样我们可以拓展一下这个思路,robots.txt文件对于我们网站来说非常重要,有时候我们需 ...