POJ 2993 Emag eht htiw Em Pleh 大模拟

本文介绍了POJ 2993 'Emag eht htiw Em Pleh'的问题背景,详细阐述了输入输出格式,并通过样例输入和输出展示了问题的具体表现。通过对题目和样例的分析,为解决ACM竞赛中的模拟题型提供了思路。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

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.|
+---+---+---+---+---+---+---+---+
 
这道题其实感觉就是把POJ2996又出了一遍,输入变输出,输出变输入,其实也是POJ2996的逆运算,先打8*8的表,将表中所有i+j得偶数的区域初始化为‘.’,奇数的初始化为‘:’,然后得到黑棋与白旗坐标,直接将棋的种类写入表的相应坐标位置,然后根据格式控制,输出即可AC此题,此题主要还是注意输入时候对字符串操作以及输出时候的格式控制,此处不是一般的坑,需要足够的耐心才可AC。
 
下面是AC代码:
 
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char chess[35][35],ch[40],ch1;
int main()
{
	int i,j,x,y;
	scanf("%s",ch);
	scanf("%s",ch);
	memset(chess,'.',sizeof(chess));
	for(i=1;i<=8;i++)
		for(j=1;j<=8;j++)
			if((i+j)%2==1)
				chess[i][j]=':';
	i=0;
	while(i<strlen(ch))
	{
		if(ch[i]>=97)
		{
			x=ch[i]+1-'a';
			i++;
			y=9-(ch[i]-'0');
			i+=2;
			chess[y][x]='P';
		}
		else
		{
			ch1=ch[i];
			i++;
			x=ch[i]+1-'a';
			i++;
			y=9-(ch[i]-'0');
			i+=2;
			chess[y][x]=ch1;
		}
	}
	scanf("%s",ch);
	scanf("%s",ch);
	i=0;
	while(i<strlen(ch))
	{
		if(ch[i]>=97)
		{
			x=ch[i]+1-'a';
			i++;
			y=9-(ch[i]-'0');
			i+=2;
			chess[y][x]='p';
		}
		else
		{
			ch1=ch[i];
			i++;
			x=ch[i]+1-'a';
			i++;
			y=9-(ch[i]-'0');
			i+=2;
			chess[y][x]=ch1+32;
		}
	}
	for(i=1;i<=8;i++)
		if(i%2==1)
			printf("+---+---+---+---+---+---+---+---+\n|.%c.|:%c:|.%c.|:%c:|.%c.|:%c:|.%c.|:%c:|\n",chess[i][1],chess[i][2],chess[i][3],chess[i][4],chess[i][5],chess[i][6],chess[i][7],chess[i][8]);
		else
            printf("+---+---+---+---+---+---+---+---+\n|:%c:|.%c.|:%c:|.%c.|:%c:|.%c.|:%c:|.%c.|\n",chess[i][1],chess[i][2],chess[i][3],chess[i][4],chess[i][5],chess[i][6],chess[i][7],chess[i][8]);
	printf("+---+---+---+---+---+---+---+---+\n");
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值