题目: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. Android Handler 原理

    在android中提供了一种异步回调机制Handler,使用它,我们可以在完成一个很长时间的任务后做出相应的通知 handler基本使用: 在主线程中,使用handler很简单,new一个Handle ...

  2. 就要从SDG离职了

    在知乎上看到有个提问,你为什么从盛大离职.我八月份在盛大游戏实习之间,下个星期准备辞职迎接新的挑战.本文也将提到我在盛大实习的经历以及离职的原因.当然,不会涉及很多SDG内部的管理以及技术上的秘密. ...

  3. 获取JAVA对象占用的内存大小

    介绍两种获取JAVA对象内存大小的方法. 第一种:Instrumentation 简介: 使用java.lang.instrument 的Instrumentation来获取一个对象的内存大小.利用I ...

  4. webstorm ftp发布问题

    通过webstorm发布遇到问题 Invalid descendent file name "/". 解决方案为 点击[Advanced options]勾选[always use ...

  5. 3、WPF学习之-布局

    一.基础知识 1.所有WPF布局容器都派生自System.Windows.Controls.Panel抽象类的面板: 2.WPF种核心布局面板有StackPanel(栈面板).WrapPanel(环绕 ...

  6. go语言实现的目录共享程序

    其实程序很小,只不过是想写点东西了.后天晚上要回学校考试了,转眼已经出来了69天了,2个月多一点.工资加上老妈赞助的钱,不知道能不能买台电脑,作为程序员一直用着i3-3217u实在难受.回去找同学拷点 ...

  7. CocoaPods - 在 Mac 中的生与死

    1. 集成 Cocoapod: 1.1 安装 ruby环境 mac 系统默认有 Ruby 环境, 通过 $ ruby -v 可以查看当前的 Ruby 版本.  如果 Ruby 版本过低可以通过 rvm ...

  8. poj 2226 Muddy Fields (转化成二分图的最小覆盖)

    http://poj.org/problem?id=2226 Muddy Fields Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  9. ParentChildTest.java

    public class ParentChildTest { public static void main(String[] args) { Parent parent=new Parent(); ...

  10. 你不需要jQuery

    http://www.webhek.com/you-do-not-need-jquery