Emag eht htiw Em Pleh

Description
This problem is a reverse case of the problem 2996. You are given the output of the problem H and your task is to find the corresponding input.
Input
according to output of problem 2996.
Output
according to input of problem 2996.
Sample Input
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
Sample Output

+---+---+---+---+---+---+---+---+
|.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.|
+---+---+---+---+---+---+---+---+
题目大意:POJ2996的反向。输入2996的输出,输出2996的输入。
解题思路:
    1.定义结构体存每个格子的状态
    2.初始化结构体数组为“:::”||“...”    
    3.读取字符串,根据数据改变结构体的第二个变量
    4.格式输出
Code:
 #include<iostream>
#include<string>
using namespace std;
struct Point
{
char a,b,c;
} P[];
void Init()
{
int ok=;
for (int i=; i<=; i++)
{
if (ok) P[i].a=P[i].b=P[i].c=':';
else P[i].a=P[i].b=P[i].c='.';
if (i%) ok=!ok;
}
}
int main()
{
char x,y;
int i,j;
string White,Black;
string tmp="+---+---+---+---+---+---+---+---+";
getline(cin,White);
getline(cin,Black);
Init();
for (i=; i<=White.length()-; i++)
{
if (White[i]>='A'&&White[i]<='Z')
{
x=White[i+],y=White[i+];
P[(x--)*+(y-'a'+)].b=White[i];
}
else if (White[i-]==',')
{
x=White[i+],y=White[i];
P[(x--)*+(y-'a'+)].b='P';
}
}
for (i=; i<=Black.length()-; i++)
{
if (Black[i]>='A'&&Black[i]<='Z')
{
x=Black[i+],y=Black[i+];
P[(x--)*+(y-'a'+)].b=Black[i]+;
}
else if (Black[i-]==',')
{
x=Black[i+],y=Black[i];
P[(x--)*+(y-'a'+)].b='p';
}
}
cout<<tmp<<endl;
for (i=; i>=; i--)
{
cout<<'|';
for (j=; j<=; j++)
cout<<P[(i-)*+j].a<<P[(i-)*+j].b<<P[(i-)*+j].c<<'|';
cout<<endl;
cout<<tmp<<endl;
}
return ;
}

POJ2993——Emag eht htiw Em Pleh(字符串处理+排序)的更多相关文章

  1. 模拟 POJ 2993 Emag eht htiw Em Pleh

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

  2. Emag eht htiw Em Pleh(imitate)

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

  3. 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: ...

  4. 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 ...

  5. 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 ...

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

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

  7. 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 ...

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

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

  9. POJ 2993:Emag eht htiw Em Pleh

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64 ...

随机推荐

  1. windows同时安装两个jdk

    两个项目需求不同,需要不同的jdk(1.7,1.8),所以每次切换项目的时候就会重新卸载原有的,在安装新的,比较麻烦. 就查资料看可以同时安装多个jdk,但是每次只能配置一个环境变量.安装的时候还是遇 ...

  2. 修改SSH端口为21

    在交流群里面有一位兄弟问到能否将ssh端口号修改为21端口,后来经过测试可以设置,具体步骤如下: 一.修改ssh配置文件的默认端口 #vim /etc/ssh/sshd_config 找到#port ...

  3. 锋利的qjuey-ajax

    jquery 中的ajax   load方法主要获取web服务器上静态数据 1 load方法载入HTML文档 load(url [,data] [,callback]) $(function(){ $ ...

  4. DTcms会员中心添加新页面-会员投稿,获得所有文章并分页

    DAL.article.cs /// <summary> /// 自定义:获得查询分页数据 /// </summary> public DataSet GetList(int ...

  5. apache配置网站目录的读写权限

    分享下apache中配置网站目录文件权限的方法. 假设http服务器运行用户和用户组是www,网站用户为centos,网站根目录是/home/centos/web. 操作方法与步骤:1,首先,设定网站 ...

  6. try catch finally 关闭流标准的写法

    平常开发中,都知道要在finlly里关闭流,但是有时finlly里代码不当,会引起另外的异常. 以下是看struts2源代码看到的,随手记录下. 有两点注意: (1)判断流是否为空. (2)filly ...

  7. 64位Python安装PIL

    写个小程序需要安装PIL,但是官网只有32位,无法找到64位安装路径.根据网上教程自行编译,但是由于VS版本问题总是提示“Python error: Unable to find vcvarsall. ...

  8. c语言指针用法

    一.指针 int t 定义整型变量 int *p p为指向整型数据的指针变量 int a[n] 定义整型数组a,它有n个元素 int *p[n] 定义指针数组p,它由n个指向整形数据的指针元素组成 i ...

  9. 使用NPIO操作Excel

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using NPOI.SS. ...

  10. fineui框架

    http://fineui.com/demo/#/demo/layout/fit.aspx 虽然比较丑陋,但功能实用 此框架比较简单, 框架的作用你懂的,重点是要有帮助文档, 进阶型的容易上手的帮助文 ...