POJ2996--Help Me with the Game(模拟题)
来源:互联网 发布:面板数据的固定效应 编辑:程序博客网 时间:2024/05/16 11:44
解题思路:
大写的为White,小写的为Black,题目要求是最后一行为第一行,第一行为最后一行。另外注意的是White的小兵的搜索方向是从下往上,而Black的小兵搜索方向为从上往下
#include<iostream>#include<cstring>#include<cstdio>using namespace std;struct node1{ int x,y;}wR[80],wB[80],wN[80],wP[80];struct node2{ int x,y;}br[80],bb[80],bn[80],bp[80];int Kx,Ky,kx,ky,Qx,Qy,qx,qy,R,r,B,b,N,n,P,p;int main(){ char map[40][40]; int i,j; for(i=16;i>=0;i--) cin>>map[i]; for(i=1;i<17;i+=2) { for(j=2;j<33;j+=4) { if(map[i][j]=='K') {Kx=(i+1)/2;Ky=(j+2)/4;}; //if(map[i][j]=='k') {kx=(i+1)/2;ky=(j+2)/4;}; if(map[i][j]=='Q') {Qx=(i+1)/2;Qy=(j+2)/4;}; //if(map[i][j]=='q') {qx=(i+1)/2;qy=(j+2)/4;}; if(map[i][j]=='R') {wR[R].x=(i+1)/2;wR[R++].y=(j+2)/4;}; //if(map[i][j]=='r') {br[r].x=(i+1)/2;br[r++].y=(j+2)/4;}; if(map[i][j]=='B') {wB[B].x=(i+1)/2;wB[B++].y=(j+2)/4;}; //if(map[i][j]=='b') {bb[b].x=(i+1)/2;bb[b++].y=(j+2)/4;}; if(map[i][j]=='N') {wN[N].x=(i+1)/2;wN[N++].y=(j+2)/4;}; //if(map[i][j]=='n') {bn[n].x=(i+1)/2;bn[n++].y=(j+2)/4;}; if(map[i][j]=='P') {wP[P].x=(i+1)/2;wP[P++].y=(j+2)/4;}; //if(map[i][j]=='p') {bp[p].x=(i+1)/2;bp[p++].y=(j+2)/4;}; } } for(i=16;i>=0;i--) { for(j=0;j<33;j++) { if(map[i][j]=='k') {kx=(i+1)/2;ky=(j+2)/4;}; if(map[i][j]=='q') {qx=(i+1)/2;qy=(j+2)/4;}; if(map[i][j]=='r') {br[r].x=(i+1)/2;br[r++].y=(j+2)/4;}; if(map[i][j]=='b') {bb[b].x=(i+1)/2;bb[b++].y=(j+2)/4;}; if(map[i][j]=='n') {bn[n].x=(i+1)/2;bn[n++].y=(j+2)/4;}; if(map[i][j]=='p') {bp[p].x=(i+1)/2;bp[p++].y=(j+2)/4;}; } } cout<<"White: "; if(Kx) printf("K%c%d,",Ky+'a'-1,Kx); if(Qx) printf("Q%c%d,",Qy+'a'-1,Qx); for(i=0;i<R;i++) printf("R%c%d,",wR[i].y+'a'-1,wR[i].x); for(i=0;i<B;i++) printf("B%c%d,",wB[i].y+'a'-1,wB[i].x); for(i=0;i<N;i++) printf("N%c%d,",wN[i].y+'a'-1,wN[i].x); for(i=0;i<P;i++) {printf("%c%d",wP[i].y+'a'-1,wP[i].x);if(i!=P-1) cout<<",";} cout<<endl; cout<<"Black: "; if(kx) printf("K%c%d,",ky+'a'-1,kx); if(qx) printf("Q%c%d,",qy+'a'-1,qx); for(i=0;i<r;i++) printf("R%c%d,",br[i].y+'a'-1,br[i].x); for(i=0;i<b;i++) printf("B%c%d,",bb[i].y+'a'-1,bb[i].x); for(i=0;i<n;i++) printf("N%c%d,",bn[i].y+'a'-1,bn[i].x); for(i=0;i<p;i++) {printf("%c%d",bp[i].y+'a'-1,bp[i].x);if(i!=p-1) cout<<",";}; cout<<endl; return 0;}
0 0
- POJ2996--Help Me with the Game(模拟题)
- POJ2996 Help Me with the Game 模拟题
- Help Me with the Game(poj2996模拟)
- POJ2996 Help Me with the Game(未完待续,模拟)
- POJ2996《Help Me with the Game》方法:模拟
- poj2996 Help Me with the Game
- poj2996--Help Me with the Game
- POJ2996 - Help Me with the Game
- poj2996--Help Me with the Game
- POJ2996,Help Me with the Game,棋盘模拟,同水且繁
- Help Me with the Game(模拟法)
- 模拟 Help Me with the Game 2996
- POJ 2996:Help Me with the Game 模拟题
- poj 2996 Help Me with the Game(模拟)
- poj_2996 Help Me with the Game(模拟)
- POJ 2996Help Me with the Game(模拟)
- POJ 2996 Help Me with the Game(模拟)
- POJ 2996 Help Me with the Game(模拟)
- 在Ubuntu 11.04 下面,Mplayer安装
- Java枚举实现单例模式
- cs61a课程总结--lecture7 递归(和一种数据结构)
- 查找增强的方法
- Javascript使div旋转倾斜 Matrix
- POJ2996--Help Me with the Game(模拟题)
- hibernate学习之Hibernate API
- 折腾开源WRT的AC无线路由之路-2
- STM32F4读写内部FLASH【使用库函数】
- visio中制作的图粘贴到word中再裁剪边缘的方法
- JAVA中字符串(\)、(\\)、(/)之间的替换
- Win7下IIS报503Service Unavailable错误的解决
- Ubuntu14.04搭建Robocup2D仿真平台的一些问题处理方法
- 分治 hdu 1007 最近点问题