Emag eht htiw Em Pleh(imitate)

Emag eht htiw Em Pleh

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 2901   Accepted: 1917

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

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<ctype.h>
 4 char chess[20][40] ;
 5 char st[40] = "+---+---+---+---+---+---+---+---+" ;
 6 char s1[40] = "|...|:::|...|:::|...|:::|...|:::|" ,s2[40] = "|:::|...|:::|...|:::|...|:::|...|" ;
 7 char color[100] ;
 8 char ch ;
 9 int row , col;
10
11 int main ()
12 {
13    // freopen ("a.txt" , "r" , stdin) ;
14     for (int i = 1 ; i <= 17 ; i++) {
15         if (i & 1) {
16             strcpy (chess[i] , st) ;
17         }
18         else {
19             if ((i >> 1) & 1)
20                 strcpy (chess[i] , s1) ;
21             else
22                 strcpy (chess[i] , s2) ;
23         }
24     }
25     gets (color) ;
26     int len = strlen (color) ;
27     color [len] = ‘,‘ ;
28     color [len + 1] = ‘\0‘ ;
29     color [6] = ‘,‘ ;
30
31     for (int i = 7 ; color[i] != ‘\0‘ ; i ++) {
32         int cnt = 0 ;
33         if (color[i] == ‘,‘) {
34             for (int j = i - 1 ; cnt < 3 ; j-- , cnt++) {
35                 if (cnt == 0)
36                     row = (9 - (color[j] - ‘0‘) ) * 2 ;
37                 if (cnt == 1)
38                     col = (color [j] - ‘a‘) * 4 + 2 ;
39                 if (cnt == 2) {
40                     if (color[j] == ‘,‘)
41                         ch = ‘P‘ ;
42                     else
43                         ch = color[j] ;
44                 }
45             }
46         }
47         chess[row][col] = ch ;
48     }
49
50     gets (color) ;
51     len = strlen (color) ;
52     color [len] = ‘,‘ ;
53     color [len + 1] = ‘\0‘ ;
54     color [6] = ‘,‘ ;
55
56     for (int i = 7 ; color[i] != ‘\0‘ ; i ++) {
57         int cnt = 0 ;
58         if (color[i] == ‘,‘) {
59             for (int j = i - 1 ; cnt < 3 ; j-- , cnt++) {
60                 if (cnt == 0)
61                     row = (9 - (color[j] - ‘0‘) ) * 2 ;
62                 if (cnt == 1)
63                     col = (color [j] - ‘a‘) * 4 + 2 ;
64                 if (cnt == 2) {
65                     if (color[j] == ‘,‘)
66                         ch = ‘p‘ ;
67                     else
68                         ch = tolower (color[j]) ;
69                 }
70             }
71         }
72         chess[row][col] = ch ;
73     }
74
75     for (int i = 1 ; i <= 17 ; i++)
76         puts (chess[i]) ;
77
78     return 0 ;
79 }

时间: 2024-11-05 23:21:55

Emag eht htiw Em Pleh(imitate)的相关文章

POJ 2993 Emag eht htiw Em Pleh (模拟)(strtok 应用)

http://www.zhuke.com/user/zkuser48082492?1r7R=123.baidu.com&eu=&lvhttp://www.zhuke.com/user/zkuser74628816?1r7R=123.baidu.com&eu=&lvhttp://www.zhuke.com/user/zkuser8162521?1r7R=123.baidu.com&eu=&lvhttp://www.zhuke.com/user/zkuser67

POJ2993——Emag eht htiw Em Pleh

Emag eht htiw Em Pleh DescriptionThis 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.Inputaccording to output of problem 2996.Outputaccording to input of probl

快速切题 poj 2993 Emag eht htiw Em Pleh 模拟

Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted: 1865 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 correspond

Poj 2993 Emag eht htiw Em Pleh

1.Link: http://poj.org/problem?id=2993 2.Content: Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2801   Accepted: 1861 Description This problem is a reverse case of the problem 2996. You are given the output of the

模拟 + 打表 --- Emag eht htiw Em Pleh

Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2578   Accepted: 1731 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 correspond

poj2993(Emag eht htiw Em Pleh)

题目大意: 给你白棋子的位置: 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模拟出棋盘的情况a-h代表横坐标,1-17代表纵坐标.后面的位置首歌字符没有大写字母的是P,其中白棋子p是大写,黑棋子p是小写.解题思路:一句话太恶心,模拟一小时,我都晕了.代码: 1 #include <algorit

POJ 2993 Emag eht htiw Em Pleh 模拟

http://poj.org/problem?id=2993 模拟大法好. 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 char q[10],w[100]; 6 char e[10],r[100]; 7 char white[12]= {'K','Q','R','B','N','P'}; 8 char black[12]= {'k','q','r

POJ-2993 Emag eht htiw Em Pleh---棋盘模拟

题目链接: https://vjudge.net/problem/POJ-2993 题目大意: 输入和输出和这里相反. 思路: 模拟题,没啥算法,直接模拟,不过为了代码精简,还是花了一点心思的 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 #include<queue> 7 #i

EM算法(1):K-means 算法

目录 EM算法(1):K-means 算法 EM算法(2):GMM训练算法 EM算法(3):EM算法详解 EM算法(1) : K-means算法 1. 简介 K-means算法是一类无监督的聚类算法,目的是将没有标签的数据分成若干个类,每一个类都是由相似的数据组成.这个类的个数一般是认为给定的. 2. 原理 假设给定一个数据集$\mathbf{X} = \{\mathbf{x}_1, \mathbf{x}_2,...,\mathbf{x}_N \}$, 和类的个数K.我们的每个类都用一个中心点$