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

题意:和2996反着

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std; struct node
{
int x,y;
char ch;
}q[];
bool cmp(node a,node b)
{
if(a.x!=b.x) return a.x>b.x;
return a.y<b.y;
} int main()
{
int sum=,i,j,t=;
char c,a,b,d; scanf("White:");
while(scanf("%c",&c)&&c!='\n')
{
cin>>a>>b;
if(b>='a'&&b<='z')
{
cin>>d;
q[sum].ch=a; q[sum].x=d-; q[sum++].y=b-;
}
else
{
q[sum].ch='P'; q[sum].x=b-; q[sum++].y=a-;
}
}
scanf("Black:");
while(scanf("%c",&c)&&c!='\n')
{
cin>>a>>b;
if(b>='a'&&b<='z')
{
cin>>d;
q[sum].ch=a+; q[sum].x=d-; q[sum++].y=b-;
}
else
{
q[sum].ch='p'; q[sum].x=b-; q[sum++].y=a-;
}
}
sort(q,q+sum,cmp);
for(i=; i>=; i--)
{
printf("+---+---+---+---+---+---+---+---+\n");
for(j=; j<; j++)
{
if((i+j)%==) a='.';
else a=':';
if(q[t].x==i&&q[t].y==j&&t<sum)
{printf("|%c%c%c",a,q[t].ch,a); t++;}
else
printf("|%c%c%c",a,a,a);
}
cout<<"|"<<endl;
}
printf("+---+---+---+---+---+---+---+---+\n");
return ;
}
05-04 03:15