题目: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. Hibernate Cascade & Inverse

    Cascade - 修改实体表 Inverse - 修改中间表 http://www.cnblogs.com/amboyna/archive/2008/02/18/1072260.html 1.到底在 ...

  2. php array_walk 和 array_reduce函数

    1.array_walk:将数组中的元素(键+值)依次取出传给处理的函数,函数处理完就完了,没有返回值. $arr1=array( 'name'=>'zhangsan', 'age'=>3 ...

  3. json数据与字符串相互转化的例子

    json与字符串之间的转换,本文分享一个小例子.   json转成string[需要引用json2.js文件]:  var arr=[{id:'id',name:'Spring'},{id:'id2' ...

  4. Python调用C模块以及性能分析

    一.c,ctypes和python的数据类型的对应关系 ctypes type ctype Python type c_char char 1-character string c_wchar wch ...

  5. cc2640-各DEMO板性能分析

    一.测试方法: 将4种模块同时上电,测量每个模块达到的最远距离.以稳定能建立通讯为连接上依据.4种板子分析为 1号阿莫DEMO板,2号咱们自己DEMO板,3号嘉源电子DEMO,4号陆程电子DEMO 全 ...

  6. 2016022601 - redis入门了解

    今天开始学习redis,先从网页上学习,主要学习地址是:易百中的redis和redis中国网站. 此片章学习来自于自:http://www.yiibai.com/redis/redis_quick_g ...

  7. SQL Server 2008 的gis函数

    居然不知道sql有gis函数,孤陋寡闻了 https://msdn.microsoft.com/zh-cn/library/bb933904.aspx   STContains(geometry 数据 ...

  8. mybatis显示sql语句 log4j.properties配置文件

    log4j.properties配置如下: 将ibatis log4j运行级别调到DEBUG可以在控制台打印出ibatis运行的sql语句,方便调试: ### 设置Logger输出级别和输出目的地 # ...

  9. pageControl指示器和图片放大-b

    小编由于篇幅问题,截取了最后一篇,如果需要看其他的三篇文章,可以去笔者的简书看:http://www.jianshu.com/users/9f3739421d15/latest_articles 另外 ...

  10. html 设置Select options值进行绑定

    <select id="cdms"> <option value="">请选择...</option> <option ...