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

Source



/*
棋盘的还原;
*/
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
//const int Maxn=1100000;
char str[]="+---+---+---+---+---+---+---+---+";//奇数行输出;
char s1[]="|:::|...|:::|...|:::|...|:::|...|";//4的倍数行的选择;
char s2[]="|...|:::|...|:::|...|:::|...|:::|";//2的倍数行的选择;
char Map[55][55];//标记每行每列的字符;
void Trans(char s[])//位置坐标转化为字母;
{
    bool flag=false;
    if(s[0]=='B')//黑棋;
        flag=true;
    for(int i=7;s[i];)
    {
        if(s[i]>='A'&&s[i]<='Z')
        {
            int u=s[i+1]-'a'+1;//纵坐标的标记;
            int  v=s[i+2]-'0';//横坐标的标记;
            if(flag)
            {
                Map[v][u]=s[i]+32;//黑棋代表的是小写字母;
            }
            else
            {
                Map[v][u]=s[i];//白棋即大写字母;
            }
            i+=4;
        }
        else if(s[i]>='a'&&s[i]<='z')//p位置的确定;
        {
            int u=s[i]-'a'+1;//纵坐标
            int v=s[i+1]-'0';//横坐标;
            if(flag)
                Map[v][u]='p';//黑棋;
            else
                Map[v][u]='P';//白棋;
                i+=3;
        }
    }
}
int main()
{
    char white[110];
    char black[110];
    memset(white,'\0',sizeof(white));
    memset(black,'\0',sizeof(black));
    //getchar();
    gets(white);
    gets(black);
    memset(Map,0,sizeof(Map));
    Trans(white);
    Trans(black);
    int u=8;//共八行;;
    for(int i=17;i>=1;i--)
    {
        if(i%2)
        {
            printf("%s\n",str);
        }
        else
        {
            int ans=2;
            int v=1;
            if((i/2)%2)//
            {
                for(int j=0;j<33;j++)
                {
                    if(j!=ans)//不是棋子;
                    {
                        printf("%c",s1[j]);
                    }
                    else
                    {
                        if(Map[u][v])//有棋子;
                        {
                            printf("%c",Map[u][v]);
                        }
                        else
                            printf("%c",s1[j]);
                          v++;//纵坐标加一;
                        ans+=4;
                    }
                }
            }
            else
            {
                for(int j=0;j<33;j++)
                {
                    if(j!=ans)
                    {
                        printf("%c",s2[j]);
                    }
                    else
                   {
                       if(Map[u][v])
                       {
                           printf("%c",Map[u][v]);
                       }
                       else
                       {
                           printf("%c",s2[j]);
                       }
                       v++;
                       ans+=4;
                   }
                }
            }
            printf("\n");
            u--;
        }
    }
    return 0;
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值