POJ-2993-Emag eht htiw Em Pleh

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

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

CTU Open 2005



#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    int i,j,t=0;
    char str1[1000],st1[100];
    char str2[1000],st2[100];
    char MAP[20][40];
    memset(MAP,0,sizeof(MAP));
    scanf("%s %s",st1,str1);
    scanf("%s %s",st2,str2);
    int len1,len2,a,b;
    len1=strlen(str1);
    len2=strlen(str2);
    for(i=0;i<len1;)
    {
        if(str1[i]=='K'||str1[i]=='Q'||str1[i]=='R'||str1[i]=='B'||str1[i]=='N')
        {
            b=(str1[i+1]-'a')*4+2;
            a=('8'-str1[i+2])*2+1;
            MAP[a][b]=str1[i];
            //printf("%c %d %d\n",MAP[a][b],a,b);
            i=i+4;
        }
        else
        {
            b=(str1[i]-'a')*4+2;
            a=('8'-str1[i+1])*2+1;
            MAP[a][b]='P';
            //printf("%c %d %d\n",MAP[a][b],a,b);
            i=i+3;
        }
    }
    //printf("\n***\n");
    for(i=0;i<len2;)
    {
        if(str2[i]=='K'||str2[i]=='Q'||str2[i]=='R'||str2[i]=='B'||str2[i]=='N')
        {
            b=(str2[i+1]-'a')*4+2;
            a=('8'-str2[i+2])*2+1;
            MAP[a][b]=str2[i]+32;
            //printf("%c %d %d\n",MAP[a][b],a,b);
            i=i+4;
        }
        else
        {
            b=(str2[i]-'a')*4+2;
            a=('8'-str2[i+1])*2+1;
            MAP[a][b]='p';
           //printf("%c %d %d\n",MAP[a][b],a,b);
            i=i+3;
        }
    }
//输出棋谱
    for(i=0;i<17;i++)
    {
        if(i%2==0)
            cout<<"+---+---+---+---+---+---+---+---+"<<endl;
        else
        {
            for(j=0;j<33;j++)
            {
                if(j%4==0)
                    printf("|");
                else if((j-1)%8==0||(j-3)%8==0)
                {
                    if(t%2==0)
                        printf(".");
                    else
                        printf(":");
                }
                else if((j-5)%8==0||(j-7)%8==0)
                {
                    if(t%2==0)
                        printf(":");
                    else
                        printf(".");
                }
                else
                {
                    if(MAP[i][j])
                        printf("%c",MAP[i][j]);
                    else
                    {
                        if((j-2)%8==0)
                        {
                            if(t%2==0)
                                printf(".");
                            else
                                printf(":");
                        }
                        else
                        {
                            if(t%2==0)
                                printf(":");
                            else
                                printf(".");
                        }
                    }
                }
            }
            printf("\n");
            t++;
        }
    }
    return 0;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值