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

题意:给出 棋盘 情况 输出 白棋 和 黑棋在 棋盘上的 白棋为大写字母 黑棋为小写字母 棋盘 左下点为原点(1,a) 输出 是 按照KQRBNP的顺序

白棋 输出 行小的 行相同按列小的 先输出 黑棋 行大的先输出

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std; struct node
{
int p,x,y;
char ch;
}b[],w[]; int tran(char c)
{
if(c=='K'||c=='k') return ;
if(c=='Q'||c=='q') return ;
if(c=='R'||c=='r') return ;
if(c=='B'||c=='b') return ;
if(c=='N'||c=='n') return ;
if(c=='P'||c=='p') return ;
return ;
}
bool cmp_w(node x,node y)
{
if(x.p!=y.p) return x.p<y.p;
if(x.x!=y.x) return x.x<y.x;
return x.y<y.y;
} bool cmp_b(node x,node y)
{
if(x.p!=y.p) return x.p<y.p;
if(x.x!=y.x) return x.x>y.x;
return x.y<y.y;
}
int main()
{
int sum_b=,sum_w=,i,j;
char s[],a;
for(i=; i>=; i--)
{
gets(s);
for(j=; j<; j++)
{
getchar(); getchar();
scanf("%c",&a);
getchar();
if(a=='.'||a==':')
continue;
if(a>='A'&&a<='Z')
{
w[sum_w].x=i;
w[sum_w].y=j;
w[sum_w].p=tran(a);
w[sum_w++].ch=a;
}
else
{
b[sum_b].x=i;
b[sum_b].y=j;
b[sum_b].p=tran(a);
b[sum_b++].ch=a;
}
}
getchar(); getchar();
}
gets(s);
sort(w,w+sum_w,cmp_w);
sort(b,b+sum_b,cmp_b);
printf("White: ");
for(i=; i<sum_w; i++)
{
if(w[i].ch!='P')
printf("%c",w[i].ch);
if(i!=sum_w-)
printf("%c%d,",w[i].y+,w[i].x);
else
printf("%c%d\n",w[i].y+,w[i].x);
}
printf("Black: ");
for(i=; i<sum_b; i++)
{
if(b[i].ch!='p')
printf("%c",b[i].ch-);
if(i!=sum_b-)
printf("%c%d,",b[i].y+,b[i].x);
else
printf("%c%d\n",b[i].y+,b[i].x);
} return ;
}

poj 2996 Help Me with the Game(模拟)的更多相关文章

  1. 模拟 POJ 2996 Help Me with the Game

    题目地址:http://poj.org/problem?id=2996 /* 题意:给出白方和黑方的棋子和对应的坐标,输出该副棋盘的样子 模拟题 + 结构体排序:无算法,switch区分读入的字符,按 ...

  2. POJ 2996 &amp; 2993 国际象棋布局 模拟

    Description Your task is to read a picture of a chessboard position and print it in the chess notati ...

  3. 快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0

    Help Me with the Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3510   Accepted:  ...

  4. Poj 2996 Help Me with the Game

    1.Link: http://poj.org/problem?id=2996 2.Content: Help Me with the Game Time Limit: 1000MS   Memory ...

  5. poj 1338 Ugly Numbers(丑数模拟)

    转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:id=1338&q ...

  6. POJ 3371 Flesch Reading Ease 无聊恶心模拟题

    题目:http://poj.org/problem?id=3371 无聊恶心题,还是不做的好,不但浪费时间而且学习英语. 不过为了做出点技术含量,写了个递归函数... 还有最后判断es,ed,le时只 ...

  7. 【POJ 3279 Fliptile】开关问题,模拟

    题目链接:http://poj.org/problem?id=3279 题意:给定一个n*m的坐标方格,每个位置为黑色或白色.现有如下翻转规则:每翻转一个位置的颜色,与其四连通的位置都会被翻转,但注意 ...

  8. 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted:  ...

  9. 【BZOJ3502/2288】PA2012 Tanie linie/【POJ Challenge】生日礼物 堆+链表(模拟费用流)

    [BZOJ3502]PA2012 Tanie linie Description n个数字,求不相交的总和最大的最多k个连续子序列. 1<= k<= N<= 1000000. Sam ...

随机推荐

  1. Cassandra1.2文档学习(17)—— CQL数据模型(上)

    参考文档:http://www.datastax.com/documentation/cql/3.0/webhelp/index.html#cql/ddl/ddl_anatomy_table_c.ht ...

  2. 用PHP生成随机数的函数

    转自:http://www.jbxue.com/article/5034.html 介绍:在早期的php中生成一个随机字符串时,总是先创建一个字符池,然后用一个循环和mt_rand()或rand()生 ...

  3. python字典操作

    Python字典是另一种可变容器模型,且可存储任意类型对象,如字符串.数字.元组等其他容器模型.一.创建字典字典由键和对应值成对组成.字典也被称作关联数组或哈希表.基本语法如下: 代码如下: dict ...

  4. go语言使用redis —— redigo

    redis的client有好多好多,go语言的client在redis官方有两个推荐,radix和redigo.选择哪一个好呢?确实很纠结,后来掷硬币决定选择redigo了. redis.go.red ...

  5. C#...何时需要重写ToString()方法?

    一般类型,都是继承自System.Object类,默认情况下,object类的ToString方法会返回当前类的类型的字符串表达形式.但也有例外!! DateTime,它就重写ToString方法,D ...

  6. ios播放声音中断后台音乐的问题

      今天遇到一个ios播放声音中断后台音乐的问题,在我的app中如果调用AVAudioSession 播放完声音,后台的qq音乐偶尔不能恢复,而网易云音乐一次都不能恢复播放,研究了一下AVAudioS ...

  7. To change the sharepoint CA port

    Set-SPCentralAdministration -Port <port number> to fix the error: Got this error: Failed to re ...

  8. 提升网站性能之设置gzip

    tomcat如何设置gzip: http://www.tuicool.com/articles/aMRRFre http://blog.csdn.net/xuefeng0707/article/det ...

  9. SCRUM,一个采用迭代,增量方法来优化可预见控制风险

    Scrum是一个用于开发和维持复杂产品的框架,是一个增量的,迭代的开发过程.在这个框架中,整个开发过程是由若干个短的迭代周期组成,一个短的迭代周期称为一个Sprint,每个Sprint的建议长度是2到 ...

  10. 彻底弄懂LSH之simHash算法

    马克·吐温曾经说过,所谓经典小说,就是指很多人希望读过,但很少人真正花时间去读的小说.这种说法同样适用于“经典”的计算机书籍. 最近一直在看LSH,不过由于matlab基础比较差,一直没搞懂.最近看的 ...