Emag eht htiw Em Pleh

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


#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<climits>
using namespace std;
char map[18][34]={
    "+---+---+---+---+---+---+---+---+",
    "|:::|...|:::|...|:::|...|:::|...|",
    "+---+---+---+---+---+---+---+---+",
    "|...|:::|...|:::|...|:::|...|:::|",
    "+---+---+---+---+---+---+---+---+",
    "|:::|...|:::|...|:::|...|:::|...|",
    "+---+---+---+---+---+---+---+---+",
    "|...|:::|...|:::|...|:::|...|:::|",
    "+---+---+---+---+---+---+---+---+",
    "|:::|...|:::|...|:::|...|:::|...|",
    "+---+---+---+---+---+---+---+---+",
    "|...|:::|...|:::|...|:::|...|:::|",
    "+---+---+---+---+---+---+---+---+",
    "|:::|...|:::|...|:::|...|:::|...|",
    "+---+---+---+---+---+---+---+---+",
    "|...|:::|...|:::|...|:::|...|:::|",
    "+---+---+---+---+---+---+---+---+"
};//上下颠倒制作地图,方便判断字母行数
char White[100],Black[100],Wnull[10],Bnull[10];


int main()
{
    cin>>Wnull>>White>>Bnull>>Black;//输入
    if(strcmp(Wnull,"Black:")==0)//如果先输入的Black则交换一下White[]和Black[]
    {
        char swap[100];
        strcpy(swap,White);
        strcpy(White,Black);
        strcpy(Black,swap);
    }
    for(int i=0;;i++)
    {
        if(White[i*4]<='A'||White[i*4]>='Z')//若不是大写字母时跳出循环
            break;
        char c=White[i*4];//记录字母
        int l=White[i*4+1]-'a';//记录字母的列数
        int r=White[i*4+2]-'1';//记录字母的行数
        map[r*2+1][l*4+2]=c;//把字母填入map
    }
    for(int i=strlen(White)-1;i>=0;i-=3)
    {
        
        int l=White[i-1]-'a';//记录P的列数
        int r=White[i]-'1';//记录P的行数
        map[r*2+1][l*4+2]='P';//将P填入map
        if(i-5>=0&&White[i-5]>='A'&&White[i-5]<='Z')//若不是表示P的位置时跳出循环
            break;
    }
    for(int i=0;;i++)
    {
        if(Black[i*4]<='A'||Black[i*4]>='Z')
            break;
        char c=Black[i*4]-'A'+'a';//同上
        int l=Black[i*4+1]-'a';
        int r=Black[i*4+2]-'1';
        map[r*2+1][l*4+2]=c;
    }
    for(int i=strlen(Black)-1;i>=0;i-=3)
    {
        
        int l=Black[i-1]-'a';
        int r=Black[i]-'1';
        map[r*2+1][l*4+2]='p';
        if(i-5>=0&&Black[i-5]>='A'&&Black[i-5]<='Z')
            break;
    }
    for(int i=16;i>=0;i--) // 倒序输出
        cout<<map[i]<<endl;
    return 0;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值