题目传送门

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

本题跟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. python 基础(文件)

    文件句柄:可简单理解为应该内存对象 open()函数  参考 https://www.runoob.com/python3/python3-file-methods.html 读.写.追加 ''' t ...

  2. 代码实现排列组合【Java】

    一.代码实现 package zhen; import java.util.Arrays; public class Arrangement { /** * 计算阶乘数,即n! = n * (n-1) ...

  3. 【转载】TX - row lock contention 的一些场景

    TX - row lock contention 的一些场景 原创 2016-07-11 易欣 云和恩墨 易欣(Eson) 云和恩墨技术专家 本文整理来自7月7日周四晚云和恩墨大讲堂嘉宾易欣分享的主题 ...

  4. day 06 预科

    目录 if判断 if判断习题 for循环 for循环习题 微信机器人 if判断 # 一条狗朝你过来了,你会干吗? 判断: 如果狗是大长腿牵来的狗--->打招呼:如果是条疯狗,跑. # if:如果 ...

  5. MySQL修炼之路五

    1. 存储引擎和锁 1. 存储引擎(处理表的处理器) 1. 基本操作 1. 查看所有存储引擎 mysql>show engines; 2. 查看已有表的存储引擎 mysql>show cr ...

  6. ELK Stack部署

    部署ELK Stack 官网:https://www.elastic.co 环境准备: ip hostname 服务 用户.组 192.168.20.3 node2003 kibana6.5,file ...

  7. jenkins使用邮件功能

    jenkins发送邮件 在日常构建后,需要及时将构建结果发送给相应的人员.这时就可以使用jenkins自带的邮件配置系统. 1 开通邮箱的SMTP服务,需要发送短信验证开启 2 进入"系统管 ...

  8. springboot+mybatis +yml文件配置多数据源

    记录一下java开发中多数据源的配置过程, 参考博客:https://blog.csdn.net/weinichendian/article/details/72903757,我在这里进行了整理,使用 ...

  9. beta版本——第五次冲刺

    第五次冲刺 (1)SCRUM部分☁️ 成员描述: 姓名 李星晨 完成了哪个任务 界面优化 花了多少时间 2h 还剩余多少时间 2h 遇到什么困难 没有 这两天解决的进度 2/2 后续两天的计划 完成文 ...

  10. python基础---python基础语法

    1.常用符号 逗号,枚举:一个函数有多个参数sum(1,2) 等于,赋值:把一个值,给一个变量,a=1 括号,函数的参数部分sum(x,y) 冒号,一个子过程的开始 双引号/单引号:表示字符串 运算符 ...