POJ 2996.Help Me with the Game
来源:互联网 发布:风暴英雄数据查询 编辑:程序博客网 时间:2024/06/14 21:31
题目:http://poj.org/problem?id=2996
AC代码(C++):
#include <iostream>#include <algorithm>#include <stdio.h>#include <vector>#include <queue>#include <math.h>#include <string>#include <string.h>#include <bitset>using namespace std;int main(){char b[17][33];for(int i = 0; i < 17; i++){for(int j = 0; j < 33; j++){cin>>b[i][j];}}char wn[30];int wr[30];char wc[30];int wcnt = 0;char bn[30];int br[30];char bc[30];int bcnt = 0;for(int i = 1; i <= 15; i+=2){for(int j = 2; j <= 30; j+=4){if(b[i][j]>=97&&b[i][j]<=122){bn[bcnt] = b[i][j];br[bcnt] = 8-i/2;bc[bcnt] = j/4+'a';bcnt++;}}}for(int i = 15; i >= 1; i-=2){for(int j = 2; j <= 30; j+=4){if(b[i][j]>=65&&b[i][j]<=90){wn[wcnt] = b[i][j];wr[wcnt] = 8-i/2;wc[wcnt] = j/4+'a';wcnt++;}}}cout<<"White: ";int wcntt = 0;for(int i = 0; i < wcnt; i++){if(wn[i]=='K'){cout<<"K"<<wc[i]<<wr[i];wcntt++;if(wcntt!=wcnt)cout<<',';break;}}for(int i = 0; i < wcnt; i++){if(wn[i]=='Q'){cout<<"Q"<<wc[i]<<wr[i];wcntt++;if(wcntt!=wcnt)cout<<',';break;}}for(int i = 0; i < wcnt; i++){if(wn[i]=='R'){cout<<"R"<<wc[i]<<wr[i];wcntt++;if(wcntt!=wcnt)cout<<',';}}for(int i = 0; i < wcnt; i++){if(wn[i]=='B'){cout<<"B"<<wc[i]<<wr[i];wcntt++;if(wcntt!=wcnt)cout<<',';}}for(int i = 0; i < wcnt; i++){if(wn[i]=='N'){cout<<"N"<<wc[i]<<wr[i];wcntt++;if(wcntt!=wcnt)cout<<',';}}for(int i = 0; i < wcnt; i++){if(wn[i]=='P'){cout<<wc[i]<<wr[i];wcntt++;if(wcntt!=wcnt)cout<<',';}}cout<<endl;cout<<"Black: ";int bcntt = 0;for(int i = 0; i < bcnt; i++){if(bn[i]=='k'){cout<<"K"<<bc[i]<<br[i];bcntt++;if(bcntt!=bcnt)cout<<',';break;}}for(int i = 0; i < bcnt; i++){if(bn[i]=='q'){cout<<"Q"<<bc[i]<<br[i];bcntt++;if(bcntt!=bcnt)cout<<',';break;}}for(int i = 0; i < bcnt; i++){if(bn[i]=='r'){cout<<"R"<<bc[i]<<br[i];bcntt++;if(bcntt!=bcnt)cout<<',';}}for(int i = 0; i < bcnt; i++){if(bn[i]=='b'){cout<<"B"<<bc[i]<<br[i];bcntt++;if(bcntt!=bcnt)cout<<',';}}for(int i = 0; i < bcnt; i++){if(bn[i]=='n'){cout<<"N"<<bc[i]<<br[i];bcntt++;if(bcntt!=bcnt)cout<<',';}}for(int i = 0; i < bcnt; i++){if(bn[i]=='p'){cout<<bc[i]<<br[i];bcntt++;if(bcntt!=bcnt)cout<<',';}}}总结: 水题, 后面偷懒直接一个一个输出了
阅读全文
0 0
- POJ 2996.Help Me with the Game
- Poj 2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- poj 2996 Help Me with the Game
- poj 2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- poj 2996 Help Me with the Game
- poj-2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- Poj 2996 Help Me with the Game
- POJ 2996:Help Me with the Game
- Help Me with the Game(POJ--2996
- poj 2996 Help Me with the Game
- poj 2996 Help Me with the Game
- poj 2996 Help Me with the Game
- POJ-2996-Help Me with the Game
- 二、storm任务提交原理
- T00003 Hanoi塔问题
- Spring配置切面
- JAVA之ArrayList
- 回顾大一·C语言编程3.4(2)
- POJ 2996.Help Me with the Game
- jsp动态嵌入另一个jsp页面
- Android将网页做成app-- Jsoup网络解析框架
- Yii2.0的ActionFilter类详细解读
- OPENSTACK NETWORKING 概念
- BOM(浏览器对象模型)和DOM(文档对象模型)
- [js高手之路] html5 canvas系列教程
- 关于Python+Opencv实现人脸检测的实验笔记(调用摄像头篇)
- Python扩展方法一二事