题目传送门

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

本题跟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. 2019 房多多java面试笔试题 (含面试题解析)

      本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.房多多等公司offer,岗位是Java后端开发,因为发展原因最终选择去了房多多,入职一年时间了,也成为了面试官 ...

  2. 2019 东方明珠java面试笔试题 (含面试题解析)

    本人3年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.东方明珠等公司offer,岗位是Java后端开发,最终选择去了东方明珠. 面试了很多家公司,感觉大部分公司考察的点 ...

  3. html解决空格显示问题

    在前端里面,大家都知道,html中输入空格或换行是识别不了是空格的,但是有时候需要实现,那么该如何解决呢?主要有以下几个方面: 1:常用的转义:  2:使用全角拼音,然后输入空格也可实现 3:用标签 ...

  4. JAVA基础之DBUtils与连接池

    利用DBUtils进一步简化JDBC数据库的增删改查的代码,同时利用从连接池中接取连接,进而进行简化和减少资源的消耗! 一.DBUtils: 1.DBUtils就是JDBC的简化开发工具包.需要项目导 ...

  5. unity读取Texture文件并转为Sprit

    using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; usin ...

  6. 【python】文件操作

    基本语法 open("文件名","访问方式") # 1. 打开文件 file = open("README.txt") # 2. 读取文件内 ...

  7. The Instruction Set In Cortex-M3

    The Cortex-M3 supports the Thumb-2 instruction set. This is one of the most important features of th ...

  8. DB开发规范---初稿

    1 公共约定 1.1 存储引擎 默认统一使用InnoDB引擎 1.2 字符集设定 后续新建DB默认使用utf8mb4字符集,校对规则使用utf8mb4_general_bin. 历史DB多使用utf8 ...

  9. python笔记38-使用zmail发各种邮件案例代码

    前言 本篇介绍使用zmail发各种格式的邮件,并运行成功的代码,小伙伴们只需更换自己的邮箱就可以运行起来了 content_text发送纯文本 先从最简单的发送纯文本的邮件开始,调通发送邮件的代码. ...

  10. 异常错误:在可以调用 OLE 之前,必须将当前线程设置为单线程单元(STA)模式

    最近做一个蛋疼的东西就是C#调用windows API 来操作一个摄像头,自动处理一些东西.要用到剪切板复制 粘贴功能,即 Clipboard.SetDataObject(filedic, true) ...