码迷,mamicode.com
首页 > 其他好文 > 详细

POJ2993——Emag eht htiw Em Pleh

时间:2014-06-03 15:33:20      阅读:347      评论:0      收藏:0      [点我收藏+]

标签:des   c   style   class   blog   code   

Emag eht htiw Em Pleh

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的反向。输入2996的输出,输出2996的输入。
结题思路:
    1.定义结构体存每个格子的状态
    2.初始化结构体数组为“:::”||“...”    
    3.读取字符串,根据数据改变结构体的第二个变量
    4.格式输出
Code:
bubuko.com,布布扣
 1 #include<iostream>
 2 #include<string>
 3 using namespace std;
 4 struct Point
 5 {
 6     char a,b,c;
 7 } P[10000];
 8 void Init()
 9 {
10     int ok=1;
11     for (int i=1; i<=64; i++)
12     {
13         if (ok) P[i].a=P[i].b=P[i].c=:;
14         else P[i].a=P[i].b=P[i].c=.;
15         if (i%8) ok=!ok;
16     }
17 }
18 int main()
19 {
20     char x,y;
21     int i,j;
22     string White,Black;
23     string tmp="+---+---+---+---+---+---+---+---+";
24     getline(cin,White);
25     getline(cin,Black);
26     Init();
27     for (i=7; i<=White.length()-1; i++)
28     {
29         if (White[i]>=A&&White[i]<=Z)
30         {
31             x=White[i+2],y=White[i+1];
32             P[(x-48-1)*8+(y-a+1)].b=White[i];
33         }
34         else if (White[i-1]==,)
35         {
36             x=White[i+1],y=White[i];
37             P[(x-48-1)*8+(y-a+1)].b=P;
38         }
39     }
40     for (i=7; i<=Black.length()-1; i++)
41     {
42         if (Black[i]>=A&&Black[i]<=Z)
43         {
44             x=Black[i+2],y=Black[i+1];
45             P[(x-48-1)*8+(y-a+1)].b=Black[i]+32;
46         }
47         else if (Black[i-1]==,)
48         {
49             x=Black[i+1],y=Black[i];
50             P[(x-48-1)*8+(y-a+1)].b=p;
51         }
52     }
53     cout<<tmp<<endl;
54     for (i=8; i>=1; i--)
55     {
56         cout<<|;
57         for (j=1; j<=8; j++)
58             cout<<P[(i-1)*8+j].a<<P[(i-1)*8+j].b<<P[(i-1)*8+j].c<<|;
59         cout<<endl;
60         cout<<tmp<<endl;
61     }
62     return 0;
63 }
bubuko.com,布布扣

 

 

POJ2993——Emag eht htiw Em Pleh,布布扣,bubuko.com

POJ2993——Emag eht htiw Em Pleh

标签:des   c   style   class   blog   code   

原文地址:http://www.cnblogs.com/Enumz/p/3765335.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!