Emag eht htiw Em Pleh(imitate)

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

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

Source

 #include<stdio.h>
#include<string.h>
#include<ctype.h>
char chess[][] ;
char st[] = "+---+---+---+---+---+---+---+---+" ;
char s1[] = "|...|:::|...|:::|...|:::|...|:::|" ,s2[] = "|:::|...|:::|...|:::|...|:::|...|" ;
char color[] ;
char ch ;
int row , col; int main ()
{
// freopen ("a.txt" , "r" , stdin) ;
for (int i = ; i <= ; i++) {
if (i & ) {
strcpy (chess[i] , st) ;
}
else {
if ((i >> ) & )
strcpy (chess[i] , s1) ;
else
strcpy (chess[i] , s2) ;
}
}
gets (color) ;
int len = strlen (color) ;
color [len] = ',' ;
color [len + ] = '\0' ;
color [] = ',' ; for (int i = ; color[i] != '\0' ; i ++) {
int cnt = ;
if (color[i] == ',') {
for (int j = i - ; cnt < ; j-- , cnt++) {
if (cnt == )
row = ( - (color[j] - '') ) * ;
if (cnt == )
col = (color [j] - 'a') * + ;
if (cnt == ) {
if (color[j] == ',')
ch = 'P' ;
else
ch = color[j] ;
}
}
}
chess[row][col] = ch ;
} gets (color) ;
len = strlen (color) ;
color [len] = ',' ;
color [len + ] = '\0' ;
color [] = ',' ; for (int i = ; color[i] != '\0' ; i ++) {
int cnt = ;
if (color[i] == ',') {
for (int j = i - ; cnt < ; j-- , cnt++) {
if (cnt == )
row = ( - (color[j] - '') ) * ;
if (cnt == )
col = (color [j] - 'a') * + ;
if (cnt == ) {
if (color[j] == ',')
ch = 'p' ;
else
ch = tolower (color[j]) ;
}
}
}
chess[row][col] = ch ;
} for (int i = ; i <= ; i++)
puts (chess[i]) ; return ;
}
上一篇:ButterKnife的简单使用


下一篇:Scrum Meeting 11-20151217