模拟 + 打表 --- Emag eht htiw Em Pleh
Emag eht htiw Em Pleh
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2578 | Accepted: 1731 |
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.| +---+---+---+---+---+---+---+---+
【题目来源】
【题目大意】
这题和上一题是相关联的,上一题是给棋盘让你输出棋子的坐标,这题时给坐标让你输出棋盘。
【题目分析】
先将整个棋盘的初始状态打表存放起来,然后每次都初始化,输入坐标后更新数组的值,最后输出。
思路清晰就能1A。
#include<cstdio> #include<cstring> char Map[17][33]; char Graph[17][33]= { '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', }; void make_table() { for(int i=0;i<17;i++) for(int j=0;j<33;j++) Map[i][j]=Graph[i][j]; } char w[500]; char b[500]; void update1(char c,char x1,char y1) { int x=(8-(y1-'0')+1)*2-1; int y=(x1-'a'+1)*4-2; Map[x][y]=c; } void update2(char c,char x1,char y1) { int x=(8-(y1-'0')+1)*2-1; int y=(x1-'a'+1)*4-2; Map[x][y]=c+32; } void update3(char x1,char y1) { int x=(8-(y1-'0')+1)*2-1; int y=(x1-'a'+1)*4-2; Map[x][y]='P'; } void update4(char x1,char y1) { int x=(8-(y1-'0')+1)*2-1; int y=(x1-'a'+1)*4-2; 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=0;i<len1;) { if(w[i]>='A'&&w[i]<='Z') { update1(w[i],w[i+1],w[i+2]); i+=4; } else if(w[i]>='a'&&w[i]<='z') { update3(w[i],w[i+1]); i+=3; } } for(int i=0;i<len2;) { if(b[i]>='A'&&b[i]<='Z') { update2(b[i],b[i+1],b[i+2]); i+=4; } else if(b[i]>='a'&&b[i]<='z') { update4(b[i],b[i+1]); i+=3; } } for(int i=0;i<17;i++) { for(int j=0;j<33;j++) printf("%c",Map[i][j]); puts(""); } } return 0; }
作者:北岛知寒
出处:https://www.cnblogs.com/crazyacking/p/3747979.html
版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?