国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

UVa220

2019-11-08 03:28:15
字體:
供稿:網(wǎng)友
/*** UVa220 ***/#include <iostream>using namespace std;#define maxn 8char table[maxn][maxn];inline void _L(char&);inline void _M(char&,int&,int&,int,int);int main(){ int n,tow,tob,x,y; char oper,color,input[3]; cin>>n; while(n--) { for(int i = 0; i < maxn; i++) for(int j = 0; j < maxn; j++) { cin>>table[i][j]; if( table[i][j] == 'B' ) tob++; else if( table[i][j] == 'W' ) tow++; } cin>>color; while(cin>>input && input[0] != 'Q'){ switch(input[0]) { case 'L': _L(color); break; case 'M': y = input[1] - 48; x = input[2] - 48; _M(color,tob,tow,y,x); break; default: break; } } for(int i = 0; i < maxn; i++){ for(int j = 0; j < maxn; j++) cout<<table[i][j]; cout<<endl; } cout<<endl; } return 0;}inline void _L(char& color){ char findcolor = 'B'; int r, c, lemo = 0, first=1; if (color == 'B') findcolor = 'W'; for(int vy = 0; vy < maxn; vy++) for(int vx = 0; vx < maxn; vx++) { if( table[vy][vx] == '-' ) { int flag = 0; // x if( table[vy][vx-1] == findcolor ) for(int i = vx-2; i >= 0; i--) { if(table[vy][i] == color) { flag = 1; r = vy+1; c = vx+1; break; } else if(table[vy][i] == '-') break; } if( table[vy][vx+1] == findcolor && !flag ) for(int i = vx+2; i < maxn; i++) { if(table[vy][i] == color) { flag = 1; r = vy+1; c = vx+1; break; } else if(table[vy][i] == '-') break; } // y if( table[vy+1][vx] == findcolor && !flag ) for(int i = vy+2; i < maxn; i++) { if(table[i][vx] == color) { flag = 1; r = vy+1; c = vx+1; break; } else if(table[i][vx] == '-') break; } if( table[vy-1][vx] == findcolor && !flag ) for(int i = vy-2; i >= 0; i--) { if(table[i][vx] == color) { flag = 1; r = vy+1; c = vx+1; break; } else if(table[i][vx] == '-') break; } // xy if( table[vy+1][vx+1] == findcolor && !flag ) for(int i = vy+2, j = vx+2; i < maxn && j < maxn; i++,j++) { if(table[i][j] == color) { flag = 1; r = vy+1; c = vx+1; break; } else if(table[i][j] == '-') break; } if( table[vy-1][vx+1] == findcolor && !flag) for(int i = vy-2, j = vx+2; i >=0 && j < maxn; i--,j++) { if(table[i][j] == color) { flag = 1; r = vy+1; c = vx+1; break; } else if(table[i][j] == '-') break; } if( table[vy-1][vx-1] == findcolor && !flag) for(int i = vy-2, j = vx-2; i >= 0 && j >= 0; i--,j--) { if(table[i][j] == color) { flag = 1; r = vy+1; c = vx+1; break; } else if(table[i][j] == '-') break; } if( table[vy+1][vx-1] == findcolor && !flag ) for(int i = vy+2, j = vx-2; i < maxn && j >= 0; i++,j--) { if(table[i][j] == color) { flag = 1; r = vy+1; c = vx+1; break; } else if(table[i][j] == '-') break; } if( flag ) { if(first) { cout<<"("<<r<<","<<c<<")"; first=0; lemo=1; } else { cout<<" ("<<r<<","<<c<<")"; lemo = 1; } } } } if(!lemo) { cout<<"No legal move."; color = findcolor; }
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 象山县| 兰州市| 班玛县| 酒泉市| 永寿县| 洱源县| 九龙城区| 渝北区| 江安县| 樟树市| 微博| 溆浦县| 和政县| 车险| 屏东市| 德阳市| 胶南市| 平潭县| 万载县| 台南市| 宝应县| 闵行区| 仲巴县| 义乌市| 慈利县| 丰镇市| 沾化县| 衡水市| 义乌市| 姜堰市| 伊金霍洛旗| 农安县| 莱西市| 固阳县| 晋城| 桓台县| 思南县| 富川| 昌黎县| 青岛市| 斗六市|