poj 2993 Emag eht htiw Em Pleh(模拟)

题目:http://poj.org/problem?id=2993

题意:和2996反着

 1 #include <iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<cstdlib>
 5 #include<stack>
 6 #include<queue>
 7 #include<cmath>
 8 #include<algorithm>
 9 using namespace std;
10 
11 struct node
12 {
13     int x,y;
14     char ch;
15 }q[1000];
16 bool cmp(node a,node b)
17 {
18     if(a.x!=b.x) return a.x>b.x;
19     return a.y<b.y;
20 }
21 
22 int main()
23 {
24     int sum=0,i,j,t=0;
25     char c,a,b,d;
26 
27     scanf("White:");
28     while(scanf("%c",&c)&&c!='\n')
29     {
30         cin>>a>>b;
31         if(b>='a'&&b<='z')
32         {
33             cin>>d;
34             q[sum].ch=a; q[sum].x=d-48; q[sum++].y=b-97;
35         }
36         else
37         {
38             q[sum].ch='P'; q[sum].x=b-48; q[sum++].y=a-97;
39         }
40     }
41     scanf("Black:");
42     while(scanf("%c",&c)&&c!='\n')
43     {
44         cin>>a>>b;
45         if(b>='a'&&b<='z')
46         {
47             cin>>d;
48             q[sum].ch=a+32; q[sum].x=d-48; q[sum++].y=b-97;
49         }
50         else
51         {
52             q[sum].ch='p'; q[sum].x=b-48; q[sum++].y=a-97;
53         }
54     }
55     sort(q,q+sum,cmp);
56     for(i=8; i>=1; i--)
57     {
58         printf("+---+---+---+---+---+---+---+---+\n");
59         for(j=0; j<8; j++)
60         {
61            if((i+j)%2==0) a='.';
62            else a=':';
63            if(q[t].x==i&&q[t].y==j&&t<sum)
64            {printf("|%c%c%c",a,q[t].ch,a); t++;}
65            else
66            printf("|%c%c%c",a,a,a);
67         }
68         cout<<"|"<<endl;
69     }
70     printf("+---+---+---+---+---+---+---+---+\n");
71     return 0;
72 }

 

posted @ 2013-08-05 16:02  水门  阅读(270)  评论(0编辑  收藏  举报