题目: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. htmlcleaner

    String xpath = "//div"; Object[] myNodes = node.evaluateXPath(xpath); for (Object obj : my ...

  2. Spark Streaming揭秘 Day29 深入理解Spark2.x中的Structured Streaming

    Spark Streaming揭秘 Day29 深入理解Spark2.x中的Structured Streaming 在Spark2.x中,Spark Streaming获得了比较全面的升级,称为St ...

  3. Linux恢复删除文件

    一.介绍extundelete 1.extundelete的文件恢复工具,该工具最给力的一点就是支持ext3/ext4双格式分区恢复. 2. 在实际线上恢复过程中,切勿将extundelete安装到你 ...

  4. c语言文件操作函数详解

    一.文件操作注意点: 1 打开文件时,如果打开方式加“+”,表示该文件可以“写” ; 2 退出程序一般用exit函数,正常退出参数为0,非正常退出参数为正零值 ; 3 文件的读写操作:按字符.字符串. ...

  5. 简易记事本(演示java文件io)

      演示效果:  打开txt文件 输入文字,保存 选择保存地址 生成文件 源代码: package io; import java.io.*; import java.awt.*; import ja ...

  6. 10个优秀的Objective-C和iOS开发在线视频教程

    如果你自己开发iOS应用,你肯定会发现网上有很多资源.学习编程的一个最好的方法就是自己写代码,而开始写代码的最快的方式就是看其他人怎么写.我们从海量视频和学习网站中整理出了我 如果你自己开发iOS应用 ...

  7. DB天气app冲刺二阶段第三天

    今天发现自己不能乖乖的按照计划来进行项目了.弄着这个然后不知不觉就弄到那边去了,结果就是哪边都弄不好,但又很纠结.还是要给自己一个计划白班才行,每次只是计划这一两天的根本不行.明天要指定一个计划白板, ...

  8. Code for the Homework2

    第二次作业,最近有点忙,一直没写,先发一下,关节角计算有点问题,后面抽时间改 #include<iostream> #include <Eigen/Dense> #includ ...

  9. ios 中定时器:NSTimer, CADisplayLink, GCD

    #import "ViewController.h" #import "RunloopViewController.h" @interface ViewCont ...

  10. 使用Yeoman搭建 AngularJS 应用 (7) —— 让我们搭建一个网页应用

    原文地址:http://yeoman.io/codelab/preview-inbrowser.html 开启你的服务 运行Grunt任务,通过输入下面的命令来创建一个本地Node的http服务,地址 ...