POJ 2993.Emag eht htiw Em Pleh
来源:互联网 发布:pc刷mac 编辑:程序博客网 时间:2024/06/06 03:41
题目:http://poj.org/problem?id=2993
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 w[100];char b[100];char board[17][33];memset(w,'\0',sizeof(w));memset(b,'\0',sizeof(b));memset(board,' ',sizeof(board));cin.getline(w,100);cin.getline(b,100);int cnt = 0;char tmp;int tmpr;int tmpc;for(int i = 7; w[i]!='\0'; i++){if(cnt==0&&w[i-1]==','&&(w[i+2]==','||w[i+2]=='\0')){tmp = 'P';cnt++;}if(cnt==0){tmp = w[i];cnt++;}else if(cnt==1){tmpc = w[i]-'a';cnt++;}else if(cnt==2){tmpr = 8-(w[i]-'0');cnt++;}else{board[tmpr*2+1][tmpc*4+2] = tmp;cnt=0;}}if(cnt==3)board[tmpr*2+1][tmpc*4+2] = tmp;cnt = 0;for(int i = 7; b[i]!='\0'; i++){if(cnt==0&&b[i-1]==','&&(b[i+2]==','||b[i+2]=='\0')){tmp = 'P';cnt++;}if(cnt==0){tmp = b[i];cnt++;}else if(cnt==1){tmpc = b[i]-'a';cnt++;}else if(cnt==2){tmpr = 8-(b[i]-'0');cnt++;}else{board[tmpr*2+1][tmpc*4+2] = tmp+32;cnt=0;}}if(cnt==3)board[tmpr*2+1][tmpc*4+2] = tmp+32;for(int i = 0; i < 17; i++){for(int j = 0; j < 33; j++){if(i%2==0&&j%4==0)board[i][j]='+';else if(i%2==0&&j%4!=0)board[i][j]='-';else if(i%2!=0&&j%4==0)board[i][j]='|';else if(i%2!=0&&j%4-1==0&&((j+1)/4+i/2)%2==0)board[i][j]='.';else if(i%2!=0&&j%4-1==0&&((j+1)/4+i/2)%2!=0)board[i][j]=':';else if(i%2!=0&&j%4+1==4&&((j-1)/4+i/2)%2==0)board[i][j]='.';else if(i%2!=0&&j%4+1==4&&((j-1)/4+i/2)%2!=0)board[i][j]=':';else if(board[i][j]==' '){if((j/4+i/2)%2==0)board[i][j]='.';else if((j/4+i/2)%2!=0)board[i][j]=':';}}}for(int i = 0; i < 17; i++){for(int j = 0; j < 33; j++){cout<<board[i][j];}cout<<endl;}}总结:水题, 注意Pawn的处理和开头结尾, 还有如果棋盘为空的情况
阅读全文
0 0
- POJ 2993.Emag eht htiw Em Pleh
- Poj 2993 Emag eht htiw Em Pleh
- poj 2993 Emag eht htiw Em Pleh
- POJ 2993 Emag eht htiw Em Pleh
- poj 2993 Emag eht htiw Em Pleh
- Poj 2993 Emag eht htiw Em Pleh
- POJ 2993:Emag eht htiw Em Pleh
- Emag eht htiw Em Pleh(POJ--2993
- poj 2993 Emag eht htiw Em Pleh
- POJ 2993 - Emag eht htiw Em Pleh
- poj 2993 Emag eht htiw Em Pleh
- poj 2993 Emag eht htiw Em Pleh
- POJ-2993-Emag eht htiw Em Pleh
- poj 2993 Emag eht htiw Em Pleh
- POJ-2993-Emag eht htiw Em Pleh
- poj 2993 Emag eht htiw Em Pleh
- POJ 刷题系列:2993. Emag eht htiw Em Pleh
- Emag eht htiw Em Pleh
- 不同类型的数据进行运算
- androdi接口回调机制
- 表添加字段的SQL语句写法
- 保持设备唤醒
- redis requires Ruby version >= 2.2.2问题
- POJ 2993.Emag eht htiw Em Pleh
- MySQL约束语法
- opencv其他常用数据结构
- lvs-tun原理配置
- webrtc中的h264解析
- 【资讯】东京券商所在地期待金融科技公司助其重振旗鼓
- 【国际】日本积极探索金融科技
- 【国际】直布罗陀金融监管者留意ICO增长并发布警告
- Ionic入门开发