国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 恩平市| 容城县| 日土县| 渭南市| 湟源县| 兴隆县| 丰都县| 乌拉特中旗| 玉林市| 水富县| 高平市| 米脂县| 来凤县| 光泽县| 宝清县| 张家口市| 嘉义县| 贡山| 恩平市| 尉氏县| 平阴县| 老河口市| 旅游| 佛坪县| 张家口市| 姜堰市| 凤庆县| 洛隆县| 普兰县| 阳新县| 民县| 迁西县| 焦作市| 玉树县| 吴旗县| 溆浦县| 商洛市| 珲春市| 宁南县| 丰城市| 大安市|