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

这个题与POJ2996正好反着,但个人认为,比2996好做多了,那些边边框框都挺容易输出的,剩下的注意p别忘了给输进去就行,还有白色的是大写,黑色的是小写;

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std ;
struct node
{
int row,col;//列
char ch ;
}sh[];
char s1[];
int cnt;
char z,w,x,y,u;
int i,j,k,flag;
int cmp(struct node a,struct node b)
{
if(a.row > b.row)
return ;
else if(a.row == b.row&&a.col < b.col)
return ;
return ;
}
void coutt()
{
cin>>s1;
//scanf("%c",&z);
getchar();
while(scanf("%c",&z)&&z != '\0')
{
if(z < &&z != ',')
{
scanf("%c %c",&y,&x);
cnt++;
sh[cnt].ch = z ;
sh[cnt].col = y- ;
sh[cnt].row = x- ;
}
else if(z != ',')
{
scanf("%c",&w);
cnt++;
sh[cnt].ch = 'P';
sh[cnt].col = z- ;
sh[cnt].row = w- ;
}
}
}
void couttt()
{
cin>>s1;
//scanf("%c",&z);
getchar();
while(scanf("%c",&z)&&z != '\0')
{
if(z < &&z != ',')
{
scanf("%c %c",&y,&x);
cnt++;
sh[cnt].ch = z ;
sh[cnt].col = y- ;
sh[cnt].row = x- ;
}
else if(z != ',')
{
scanf("%c",&w);
cnt++;
sh[cnt].ch = 'p';
sh[cnt].col = z- ;
sh[cnt].row = w- ;
}
}
}
int ju(int i,int j)
{
if((i+j)% == )
return ;
else return ;
}
int main()
{
cnt = ;
/*coutt();
couttt();*/
cin>>s1;
//scanf("%c",&z);
getchar();
while(scanf("%c",&z)&&(z != '\n'))
{
if(z< && z!=',')
{
scanf("%c%c",&y,&x);
cnt++;
sh[cnt].ch = z ;
sh[cnt].col = y- ;
sh[cnt].row = x- ;
}
else if(z != ',')
{
scanf("%c",&w);
cnt++;
sh[cnt].ch = 'P';
sh[cnt].col = z- ;
sh[cnt].row = w- ;
}
}
cin>>s1;
scanf("%c",&z);
while(scanf("%c",&z)&& z!='\n')
{
if(z< && z!=',')
{
scanf("%c%c",&y,&x);
cnt++;
sh[cnt].ch = z +;
sh[cnt].col = y- ;
sh[cnt].row = x- ;
}
else if(z != ',')
{
scanf("%c",&w);
cnt++;
sh[cnt].ch = 'p';
sh[cnt].col = z- ;
sh[cnt].row = w- ;
}
}
sort(sh+,sh+cnt+,cmp);
int k = ;
printf("+---+---+---+---+---+---+---+---+\n");
for(i = ; i <= ; i++)
{
for(j = ; j <= ; j++)
{
int flag = ju(i,j);
printf("|");
if(flag) printf(":");
else printf(".");
if(sh[k].col == j&&sh[k].row ==-i)
{
printf("%c",sh[k++].ch);
}
else if(flag)
printf(":");
else
printf(".");
if(flag) printf(":");
else printf(".");
}
printf("|\n+---+---+---+---+---+---+---+---+\n");
}
return ;
}
05-11 07:59