POJ2993——Emag eht htiw Em Pleh(字符串处理+排序)
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(字符串处理+排序)的更多相关文章
- 模拟 POJ 2993 Emag eht htiw Em Pleh
题目地址:http://poj.org/problem?id=2993 /* 题意:与POJ2996完全相反 模拟题 + 字符串处理:无算法,读入两行字符串找出相应点用used标记,输出时标记过的输出 ...
- Emag eht htiw Em Pleh(imitate)
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2901 Accepted: ...
- 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: ...
- 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 ...
- 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 ...
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 Accepted: ...
- 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 ...
- 模拟 + 打表 --- Emag eht htiw Em Pleh
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2578 Accepted: ...
- POJ 2993:Emag eht htiw Em Pleh
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64 ...
随机推荐
- 翻转单词顺序VS左旋转字符串
题目:输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变.句子中单词以空格符隔开.为简单起见,标点符号和普通字母一样处理.例如输入“I am a student.”,则输出“student ...
- CSS的引入方式
再用HTML编写的文本中,有是没能达到我们想要的效果,此时此刻我们可以用过引用CSS来控制!这不仅使得效果好而且代码层次清晰.CSS的引入方式可以分为四类: 1.链入外部样式表,就是把样式表保存为一个 ...
- preventDefault()、stopPropagation()、return false 之间的区别
“return false”之所以被误用的如此厉害,是因为它看起来像是完成了我们交给它的工作,浏览器不会再将我们重定向到href中的链接,表单也不会被继续提交,但这么做到底有什么不对呢? 可能在你刚开 ...
- (转)[Erlang 0080] RabbitMQ :VHost,Exchanges, Queues,Bindings and Channels
和RabbitMQ这个项目的缘分好奇怪,很长一段时间内是只关注源代码,真的是Erlang开源项目中的典范;现在要在项目中应用RabbitMQ,从新的视角切入,全新的感觉.仿佛旧情人换了新衣,虽是熟稔却 ...
- php5.3不支持 ereg、ereg_replace等函数问题,如提示:Deprecated: Function ereg() is deprecated
在php5.3中,正则函数ereg_replace已经废弃,而dedecms还继续用.有两个方案可以解决以上问题: 1.把php版本换到v5.3下. 2.继续使用v5.3,修改php.ini文件 ;e ...
- hdu 4641 K-string SAM的O(n^2)算法 以及 SAM+并查集优化
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4641 题意:有一个长度为n(n < 5e4)的字符串,Q(Q<=2e5)次操作:操作分为:在末 ...
- Linux下crontab详解
1.crond介绍 crond是Linux下的任务调度命令,让系统定期执行指定程序.crond命令每分钟都会检查是否有要执行的工作,若有要执行的程序便会自动执行. linux下任务调度工作主要分两类: ...
- 【cheerio】nodejs的抓取页面模块
http://baike.baidu.com/link?url=8V1CZsEzNE05ujOzISquom_pvFj16sWu1rRb8js11pmd9HNq7ePW_aKfG9oyXj6Txuu5 ...
- C# Windows - TabControl
TabControl控件的属性 - 一般用于控制TabPages对象容器的外观,特别是显示的选项卡的外观 属性 说明 Alignment 控制选项卡在选项卡控件的什么位置显示 Appearance 控 ...
- 在PyCharm里配置SubVersion
1.如果PyCharm不支持svn ,那么下载svn命令行安装包,下载地址:http://sourceforge.net/projects/win32svn/ 例如:安装到 D:\software\s ...