模拟 + 打表 --- Emag eht htiw Em Pleh
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2578 | Accepted: 1731 |
Description
Input
Output
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.|
+---+---+---+---+---+---+---+---+
【题目来源】
【题目大意】
这题和上一题是相关联的,上一题是给棋盘让你输出棋子的坐标,这题时给坐标让你输出棋盘。
【题目分析】
先将整个棋盘的初始状态打表存放起来,然后每次都初始化,输入坐标后更新数组的值,最后输出。
思路清晰就能1A。
#include<cstdio>
#include<cstring>
char Map[][];
char Graph[][]=
{
'+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+',
'|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|',
'+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+',
'|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',
'+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+',
'|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|',
'+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+',
'|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',
'+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+',
'|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|',
'+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+',
'|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',
'+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+',
'|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|',
'+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+',
'|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',
'+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+',
}; void make_table()
{
for(int i=;i<;i++)
for(int j=;j<;j++)
Map[i][j]=Graph[i][j];
} char w[];
char b[]; void update1(char c,char x1,char y1)
{
int x=(-(y1-'')+)*-;
int y=(x1-'a'+)*-;
Map[x][y]=c;
} void update2(char c,char x1,char y1)
{
int x=(-(y1-'')+)*-;
int y=(x1-'a'+)*-;
Map[x][y]=c+;
} void update3(char x1,char y1)
{
int x=(-(y1-'')+)*-;
int y=(x1-'a'+)*-;
Map[x][y]='P';
} void update4(char x1,char y1)
{
int x=(-(y1-'')+)*-;
int y=(x1-'a'+)*-;
Map[x][y]='p';
} int main()
{
while(scanf("White: %s",w)!=EOF)
{
getchar();
scanf("Black: %s",b);
getchar();
make_table();
int len1=strlen(w);
int len2=strlen(b);
for(int i=;i<len1;)
{
if(w[i]>='A'&&w[i]<='Z')
{
update1(w[i],w[i+],w[i+]);
i+=;
}
else if(w[i]>='a'&&w[i]<='z')
{
update3(w[i],w[i+]);
i+=;
}
}
for(int i=;i<len2;)
{
if(b[i]>='A'&&b[i]<='Z')
{
update2(b[i],b[i+],b[i+]);
i+=;
}
else if(b[i]>='a'&&b[i]<='z')
{
update4(b[i],b[i+]);
i+=;
}
}
for(int i=;i<;i++)
{
for(int j=;j<;j++)
printf("%c",Map[i][j]);
puts("");
}
}
return ;
}
模拟 + 打表 --- Emag eht htiw Em Pleh的更多相关文章
- 模拟 POJ 2993 Emag eht htiw Em Pleh
题目地址:http://poj.org/problem?id=2993 /* 题意:与POJ2996完全相反 模拟题 + 字符串处理:无算法,读入两行字符串找出相应点用used标记,输出时标记过的输出 ...
- 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 ...
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 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(imitate)
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2901 Accepted: ...
- 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 ...
- 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
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64 ...
随机推荐
- APS中生产计划排程模块的基本原理
高级计划系统(APS)作为ERP和MES的补充,用于协调物流.开发瓶颈资源和保证交货日期. APS包括需求和供应计划.运输和生产计划排程等各种供应链计划模块,本文主要介绍APS中生产计划排程模块的基本 ...
- iOS编程
一.语法 1. performSelector 2.
- 定时任务突然中止,告警:Thread starvation or clock leap detected
1.背景 定时任务告警信息如下: 02:38:24.112 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool - H ...
- itextpdf中表格中单元格的文字水平垂直居中的设置
在使用itextpdf中,版本是5.5.6,使用Doucument方式生成pdf时,设置单元格中字体的对齐方式时,发现一些问题,并逐渐找到了解决方式. 给我的经验就是:看官网的例子才能保证代码的效果, ...
- 安装php源码包内的扩展
本地环境 PHP 7.0.4 (cli) (built: Mar 13 2016 21:50:22) ( NTS ) 安装 进入源码包中的ext文件夹中 [root@test etc]# cd /us ...
- mybatis-plus手记
项目源码:https://gitee.com/baomidou/mybatis-plus https://github.com/baomidou/mybatis-plus 文档:https:/ ...
- HDU 1253 胜利大逃亡 题解
胜利大逃亡 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- 盛科(Centec)交换机 SmartConfig 特性
参考 DHCP manual pages DHCP option-66 & option-150 的区别 一. 原理 目前市场上稍微有些实力的交换机厂商,均支持自动化的批量开局部署,虽然具体实 ...
- JavaScript/JQuery自执行函数
JavaScript中任何库与框架设计的第一个要点就是解决命名空间与变量污染的问题.jQuery就是利用了JavaScript函数作用域的特性,采用自执行函数包裹了自身的方法来解决这个问题.从jQue ...
- unity texture贴图纹理
文章内一些内容引用自作者:Aimar_Johnny http://blog.csdn.net/lzhq1982/article/details/75045358 导入png图片,默认显示如下 Text ...