Emag eht htiw Em Pleh(poj1999模拟)

/*
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#problem/C
C - Emag eht htiw Em Pleh
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u
Submit
 
Status
 
Practice
 
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.|
+---+---+---+---+---+---+---+---+


Memory Time Language Length Submit Time
Accepted 216 KB 0 ms C++ 1484 B
解析:
1.题意:给出黑白棋子的位置,画出棋盘布局
2.思路:把棋盘分成64大格,用一个结构体标记黑白棋子所在位置。然后输出即可
*/
#include<stdio.h>
#include<string.h>
#include <iostream>
using namespace std;
char ch[2][200];
char s1[40]="+---+---+---+---+---+---+---+---+";
struct point
{   char le;
	int flag;
	int sign;
}p[70][70];
int main()
{
     int i,j,k,t1,t2;
     char s[2][10],st;
     for(i=0;i<2;i++)
     {cin>>s[i]>>ch[i];}
    for(k=0;k<2;k++)
    for(i=0;i<strlen(ch[k])-1;i++)
    {    st=ch[k][i];
    	if(st!=',')
    	{
    		if(st<='Z'&&st>='A')
    		{    t1=ch[k][i+1]-'a';
    	         t2=ch[k][i+2]-'0';
    	         p[t2][t1].le=ch[k][i];
    			i+=3;
    		}
	        else
    		{    t1=ch[k][i]-'a';
    	         t2=ch[k][i+1]-'0';
				 p[t2][t1].le='P';
    			 i+=2;
    		}
    		 p[t2][t1].flag=1;
    		 if(k==1)
			 p[t2][t1].sign=1;
    	}


    }


    for(i=8;i>=1;i--)
     {  int c=i%2;
     	printf("%s\n",s1);
     	 for(j=0;j<30;j+=4)
     	 {printf("|");
     	   k=j/4;
     	   	if(k%2!=c)
     	   	{
     	   		if(p[i][k].flag==1)
     	   		{
				 if(p[i][k].sign==1)
				 printf(":%c:",p[i][k].le+32);
     	   		 else
     	   		  printf(":%c:",p[i][k].le);
     	   		}
     	   		else
     	   		printf(":::");
     	   	}
     	   	else//白子
     	   	{
     	   		if(p[i][k].flag==1)
     	   		{if(p[i][k].sign==0)
     	   		printf(".%c.",p[i][k].le);
     	   		else
     	   			printf(".%c.",p[i][k].le+32);
     	   		}
     	   		else
     	   		printf("...");
			}
     	   }
     	   printf("|\n");
		}
     	 printf("%s\n",s1);


    return 0;
}



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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值