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 <algorithm>
  2 #include <iostream>
  3 #include <sstream>
  4 #include <cstdlib>
  5 #include <cstring>
  6 #include <cstdio>
  7 #include <string>
  8 #include <bitset>
  9 #include <vector>
 10 #include <queue>
 11 #include <stack>
 12 #include <cmath>
 13 #include <list>
 14 #include <map>
 15 #include <set>
 16 using namespace std;
 17 /***************************************/
 18 #define ll long long
 19 #define int64 __int64
 20 /***************************************/
 21 const int INF = 0x7f7f7f7f;
 22 const double eps = 1e-8;
 23 const double PIE=acos(-1.0);
 24 const int dx[]= {0,-1,0,1};
 25 const int dy[]= {1,0,-1,0};
 26 const int fx[]= {-1,-1,-1,0,0,1,1,1};
 27 const int fy[]= {-1,0,1,-1,1,-1,0,1};
 28 /***************************************/
 29 void openfile()
 30 {
 31     freopen("data.in","rb",stdin);
 32     freopen("data.out","wb",stdout);
 33 }
 34 /**********************华丽丽的分割线,以上为模板部分*****************/
 35 
 36 int main()
 37 {
 38     char board[18][35]=
 39     {
 40         "",
 41         " +---+---+---+---+---+---+---+---+",
 42         " |:::|...|:::|...|:::|...|:::|...|",
 43         " +---+---+---+---+---+---+---+---+",
 44         " |...|:::|...|:::|...|:::|...|:::|",
 45         " +---+---+---+---+---+---+---+---+",
 46         " |:::|...|:::|...|:::|...|:::|...|",
 47         " +---+---+---+---+---+---+---+---+",
 48         " |...|:::|...|:::|...|:::|...|:::|",
 49         " +---+---+---+---+---+---+---+---+",
 50         " |:::|...|:::|...|:::|...|:::|...|",
 51         " +---+---+---+---+---+---+---+---+",
 52         " |...|:::|...|:::|...|:::|...|:::|",
 53         " +---+---+---+---+---+---+---+---+",
 54         " |:::|...|:::|...|:::|...|:::|...|",
 55         " +---+---+---+---+---+---+---+---+",
 56         " |...|:::|...|:::|...|:::|...|:::|",
 57         " +---+---+---+---+---+---+---+---+"
 58     };
 59     char a[50][10],b[50][10];
 60     memset(a,0,sizeof(a));
 61     memset(b,0,sizeof(b));
 62     int i,j;
 63     int ce=0;
 64     int x,y;
 65     int len1=0,len2=0;
 66     for(i=0; i<50; i++)
 67     {
 68         for(j=0; j<10; j++)
 69         {
 70             scanf("%c",&a[i][j]);
 71             if (a[i][j]==','||a[i][j]==' ')
 72                 break;
 73             if (a[i][j]=='
')
 74             {
 75                 len1=i;
 76                 ce=1;
 77                 break;
 78             }
 79         }
 80         if (ce)
 81             break;
 82     }
 83     ce=0;
 84     for(i=0; i<50; i++)
 85     {
 86         for(j=0; j<10; j++)
 87         {
 88             scanf("%c",&b[i][j]);
 89             if (b[i][j]==','||b[i][j]==' ')
 90                 break;
 91             if (b[i][j]=='
')
 92             {
 93                 len2=i;
 94                 ce=1;
 95                 break;
 96             }
 97         }
 98         if (ce)
 99             break;
100     }
101     ce=0;
102     if (a[0][0]=='W')
103         ce=1;
104     if (ce)
105     {
106         for(i=1; i<=len1; i++)
107         {
108 
109             int len=strlen(a[i]);
110             if (len==4)
111             {
112                 x=a[i][1]-'a';
113                 y=a[i][2]-'0';
114                 board[y*2][x*4+3]=a[i][0];
115             }
116             if (len==3)
117             {
118                 x=a[i][0]-'a';
119                 y=a[i][1]-'0';
120                 board[y*2][x*4+3]='P';
121             }
122         }
123         for(i=1; i<=len2; i++)
124         {
125 
126             int len=strlen(b[i]);
127             if (len==4)
128             {
129                 x=b[i][1]-'a';
130                 y=b[i][2]-'0';
131                 board[y*2][x*4+3]=b[i][0]+32;
132             }
133             if (len==3)
134             {
135                 x=b[i][0]-'a';
136                 y=b[i][1]-'0';
137                 board[y*2][x*4+3]='p';
138             }
139         }
140     }
141     else
142     {
143         for(i=1; i<=len1; i++)
144         {
145 
146             int len=strlen(a[i]);
147             if (len==4)
148             {
149                 x=a[i][1]-'a';
150                 y=a[i][2]-'0';
151                 board[y*2][x*4+3]=a[i][0]+32;
152             }
153             if (len==3)
154             {
155                 x=a[i][0]-'a';
156                 y=a[i][1]-'0';
157                 board[y*2][x*4+3]='p';
158             }
159         }
160         for(i=1; i<=len2; i++)
161         {
162 
163             int len=strlen(b[i]);
164             if (len==4)
165             {
166                 x=b[i][1]-'a';
167                 y=b[i][2]-'0';
168                 board[y*2][x*4+3]=b[i][0];
169             }
170             if (len==3)
171             {
172                 x=b[i][0]-'a';
173                 y=b[i][1]-'0';
174                 board[y*2][x*4+3]='P';
175             }
176         }
177     }
178     for(i=17;i>0;i--)
179     {
180         for(j=1;j<=33;j++)
181             printf("%c",board[i][j]);
182         printf("
");
183     }
184     return 0;
185 }
186 /*
187         "+---+---+---+---+---+---+---+---+",
188         "|:::|...|:::|...|:::|...|:::|...|",
189         "+---+---+---+---+---+---+---+---+",
190         "|...|:::|...|:::|...|:::|...|:::|",
191         "+---+---+---+---+---+---+---+---+",
192         "|:::|...|:::|...|:::|...|:::|...|",
193         "+---+---+---+---+---+---+---+---+",
194         "|...|:::|...|:::|...|:::|...|:::|",
195         "+---+---+---+---+---+---+---+---+",
196         "|:::|...|:::|...|:::|...|:::|...|",
197         "+---+---+---+---+---+---+---+---+",
198         "|...|:::|...|:::|...|:::|...|:::|",
199         "+---+---+---+---+---+---+---+---+",
200         "|:::|...|:::|...|:::|...|:::|...|",
201         "+---+---+---+---+---+---+---+---+",
202         "|...|:::|...|:::|...|:::|...|:::|",
203         "+---+---+---+---+---+---+---+---+",
204 */
View Code



屌丝终有逆袭日,*******。
原文地址:https://www.cnblogs.com/ZhaoPengkinghold/p/3757920.html