poj 2996 Help Me with the Game(模拟)
题目: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(模拟)的更多相关文章
- 模拟 POJ 2996 Help Me with the Game
题目地址:http://poj.org/problem?id=2996 /* 题意:给出白方和黑方的棋子和对应的坐标,输出该副棋盘的样子 模拟题 + 结构体排序:无算法,switch区分读入的字符,按 ...
- POJ 2996 & 2993 国际象棋布局 模拟
Description Your task is to read a picture of a chessboard position and print it in the chess notati ...
- 快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0
Help Me with the Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3510 Accepted: ...
- 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 ...
- poj 1338 Ugly Numbers(丑数模拟)
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:id=1338&q ...
- POJ 3371 Flesch Reading Ease 无聊恶心模拟题
题目:http://poj.org/problem?id=3371 无聊恶心题,还是不做的好,不但浪费时间而且学习英语. 不过为了做出点技术含量,写了个递归函数... 还有最后判断es,ed,le时只 ...
- 【POJ 3279 Fliptile】开关问题,模拟
题目链接:http://poj.org/problem?id=3279 题意:给定一个n*m的坐标方格,每个位置为黑色或白色.现有如下翻转规则:每翻转一个位置的颜色,与其四连通的位置都会被翻转,但注意 ...
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 Accepted: ...
- 【BZOJ3502/2288】PA2012 Tanie linie/【POJ Challenge】生日礼物 堆+链表(模拟费用流)
[BZOJ3502]PA2012 Tanie linie Description n个数字,求不相交的总和最大的最多k个连续子序列. 1<= k<= N<= 1000000. Sam ...
随机推荐
- Spark Streaming揭秘 Day34 解析UI监听模式
Spark Streaming揭秘 Day34 解析UI监听模式 今天分享下SparkStreaming中的UI部分,和所有的UI系统一样,SparkStreaming中的UI系统使用的是监听器模式. ...
- Orcale Function Sequence
Orcale Function Sequence. 1 Create Or Replace Function F_Get_Sequence(As_Companyno In Varchar2, As_T ...
- Linux学习笔记(5)-进程管理
进程简介 进程是正在执行的一个程序或命令,每一个进程都有自己的地址空间,并占有一定的系统资源.感性的认识,进程就是一个正在运行的程序 进程管理的作用 判断服务器的运行状态 查看系统中有哪些进程 杀死进 ...
- css3实现非矩形图片效果
经常在网站上看到有一些非矩形的图片展示.在以前可能我会毫不犹豫的直接放上张处理好的图片.但是这样的话确实有些不太友好.每每需要换图的时候,都要去开图像处理软件也是蛮拼的.自从有了css3的选装,妈妈就 ...
- SSH开发框架搭建参考
一, 参考文章: 1, http://blog.csdn.net/communicate_/article/details/8644040 这篇文章讲的还算详尽,但是貌似有一些多余的代码: 2,
- hdu 4712
看了大牛的解法 第一次知道可以产生随机数解题 在计算hamming距离时用了位运算 很简便 /************************************************* ...
- sql删除wordpress没用的postmeta记录
支持多作者的wordpress博客,有时需要审核他们的文章内容,虽然UGC(User-generated content)整体是好的,但是也要控制一下质量,实在不相关或spam的文章就要毫不手软的删除 ...
- 如何通过 OAuth 2.0 使 iOS Apps 集成 LinkedIn 登录功能?
社交网络早已成为人们日常生活的一部分.其实,社交网络也是编程生活的一部分,大多数 App 必须通过某种方式与社交网络交互,传送或接收与用户相关的数据.大多数情况下,用户需要登录某种社交网络,授权 Ap ...
- 【leetcode】Intersection of Two Linked Lists(easy)
Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...
- Google chrome的字体设置
http://blog.sina.com.cn/s/blog_a3b863da01016sv3.html 谷歌浏览器(Google chrome)速度很快,很好用.问题是字体显示有时候不对:用英文版的 ...