Emag eht htiw Em Pleh(POJ--2993

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

#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
char map[20][50]=                         //初始化空棋盘
{
    "0",
    "0+---+---+---+---+---+---+---+---+",
    "0|...|:::|...|:::|...|:::|...|:::|",
    "0+---+---+---+---+---+---+---+---+",
    "0|:::|...|:::|...|:::|...|:::|...|",
    "0+---+---+---+---+---+---+---+---+",
    "0|...|:::|...|:::|...|:::|...|:::|",
    "0+---+---+---+---+---+---+---+---+",
    "0|:::|...|:::|...|:::|...|:::|...|",
    "0+---+---+---+---+---+---+---+---+",
    "0|...|:::|...|:::|...|:::|...|:::|",
    "0+---+---+---+---+---+---+---+---+",
    "0|:::|...|:::|...|:::|...|:::|...|",
    "0+---+---+---+---+---+---+---+---+",
    "0|...|:::|...|:::|...|:::|...|:::|",
    "0+---+---+---+---+---+---+---+---+",
    "0|:::|...|:::|...|:::|...|:::|...|",
    "0+---+---+---+---+---+---+---+---+"
};
int pri(char ch)
{
    if(ch=='K')
        return 0;
    if(ch=='Q')
        return 1;
    if(ch=='R')
        return 2;
    if(ch=='B')
        return 3;
    if(ch=='N')
        return 4;
    return 5;
}
int main()
{
    //freopen("aa.text","r",stdin);
    char a[10],b[100],c[10],d[100];
    scanf("%s %s",a,b);
    scanf("%s %s",c,d);
    int len1=strlen(b);  
    int len2=strlen(d);
    int xx,yy;
    for(int i=0; i<len1; i++)
    {
        if(pri(b[i])==0)
        {
            xx=(9-b[i+2]+'0')*2;               //该棋子在棋盘中相应的行数
            yy=(b[i+1]-'a')*4+3;               //该棋子在棋盘中相应的列数
            map[xx][yy]='K';
            i+=3;
        }
        else if(pri(b[i])==1)
        {
            xx=(9-b[i+2]+'0')*2;
            yy=(b[i+1]-'a')*4+3;
            map[xx][yy]='Q';
            i+=3;
        }
        else if(pri(b[i])==2)
        {
            xx=(9-b[i+2]+'0')*2;
            yy=(b[i+1]-'a')*4+3;
            map[xx][yy]='R';
            i+=3;
        }
        else if(pri(b[i])==3)
        {
            xx=(9-b[i+2]+'0')*2;
            yy=(b[i+1]-'a')*4+3;
            map[xx][yy]='B';
            i+=3;
        }
        else if(pri(b[i])==4)
        {
            xx=(9-b[i+2]+'0')*2;
            yy=(b[i+1]-'a')*4+3;
            map[xx][yy]='N';
            i+=3;
        }
        else if(pri(b[i])==5)
        {
            xx=(9-b[i+1]+'0')*2;
            yy=(b[i]-'a')*4+3;
            map[xx][yy]='P';
            i+=2;
        }
    }
    for(int i=0; i<len2; i++)
    {
        if(pri(d[i])==0)
        {
            xx=(9-d[i+2]+'0')*2;
            yy=(d[i+1]-'a')*4+3;
            map[xx][yy]='k';
            i+=3;
        }
        else if(pri(d[i])==1)
        {
            xx=(9-d[i+2]+'0')*2;
            yy=(d[i+1]-'a')*4+3;
            map[xx][yy]='q';
            i+=3;
        }
        else if(pri(d[i])==2)
        {
            xx=(9-d[i+2]+'0')*2;
            yy=(d[i+1]-'a')*4+3;
            map[xx][yy]='r';
            i+=3;
        }
        else if(pri(d[i])==3)
        {

            xx=(9-d[i+2]+'0')*2;
            yy=(d[i+1]-'a')*4+3;
            map[xx][yy]='b';
            i+=3;
        }
        else if(pri(d[i])==4)
        {
            xx=(9-d[i+2]+'0')*2;
            yy=(d[i+1]-'a')*4+3;
            map[xx][yy]='n';
            i+=3;
        }
        else if(pri(d[i])==5)
        {
            xx=(9-d[i+1]+'0')*2;
            yy=(d[i]-'a')*4+3;
            map[xx][yy]='p';
            i+=2;
        }
    }
    for(int i=1; i<=17; i++)
    {
        for(int j=1; j<=33; j++)
        {
            printf("%c",map[i][j]);
        }
        printf("\n");
    }
    return 0;
}<strong>
</strong>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值