模拟 + 打表 --- 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.|
+---+---+---+---+---+---+---+---+

【题目来源】

CTU Open 2005

【题目大意】

这题和上一题是相关联的,上一题是给棋盘让你输出棋子的坐标,这题时给坐标让你输出棋盘。

【题目分析】

先将整个棋盘的初始状态打表存放起来,然后每次都初始化,输入坐标后更新数组的值,最后输出。

思路清晰就能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 ;
}
上一篇:Python基础s14-day1


下一篇:ButterKnife的简单使用