poj2993

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

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<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<malloc.h>
#include<math.h>
char  chess[40][40];
int return_y(char ch){
    switch(ch){
        case 'a':return 0;
        case 'b':return 1;
        case 'c':return 2;
        case 'd':return 3;
        case 'e':return 4;
        case 'f':return 5;
        case 'g':return 6;
        case 'h':return 7;
    }
}
int return_x(char ch){
    switch(ch){
        case '1' :return 1;
        case '2' :return 2;
        case '3' :return 3;
        case '4' :return 4;
        case '5' :return 5;
        case '6' :return 6;
        case '7' :return 7;
        case '8' :return 8;
    }
}
int main(){
    char a[40]="+---+---+---+---+---+---+---+---+";
    char b[40]="|...|:::|...|:::|...|:::|...|:::|";
    char c[40]="|:::|...|:::|...|:::|...|:::|...|";
    char black[400];
    char white[400];
    int i,j;
    j=0;
    for(i=0.;i<17;i++){
        if(i%2!=0){
            if(j%2==0)
                strcpy(chess[i],b);
            else
                strcpy(chess[i],c);
            j++;
        }
        else
            strcpy(chess[i],a);
    }
    //printf("%d %d %d %d",'A','Z','a','z');
    gets(white);
    gets(black);
    int len;
    len=strlen(white);
    i=6;
    int x,y;
    while(i<len){
        if(white[i]==' '||white[i]==','){
            if(white[i+1]>=65&&white[i+1]<=90){
                y=return_y(white[i+2])*4+2;
                x=(8-return_x(white[i+3]))*2+1;
                chess[x][y]=white[i+1];
                i+=4;
            }
            else{
                y=return_y(white[i+1])*4+2;
                x=(8-return_x(white[i+2]))*2+1;
                chess[x][y]='P';
                i+=3;
            }
        }
    }
    i=6;
    while(i<len){
        if(black[i]==' '||black[i]==','){
            if(black[i+1]>=65&&black[i+1]<=90){
                y=return_y(black[i+2])*4+2;
                x=(8-return_x(black[i+3]))*2+1;
                chess[x][y]=black[i+1]+32;
                i+=4;
            }
            else{
                y=return_y(black[i+1])*4+2;
                x=(8-return_x(black[i+2]))*2+1;
                chess[x][y]='p';
                i+=3;
            }
        }
    }
    for(i=0;i<17;i++)
        puts(chess[i]);
    return 0;
}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值