poj 2361 Tic Tac Toe 五子棋模拟

来源:互联网 发布:不抄袭的网络作家 编辑:程序博客网 时间:2024/05/16 06:35
//poj 2361//sep9//与poj3075的区别是在游戏中的状态也合法#include <iostream>#include <algorithm>using namespace std;int way[8][3]={{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};char s[16];bool check(char c){for(int i=0;i<8;++i){int j;for(j=0;j<3;++j)if(s[way[i][j]]!=c)break;if(j==3)return true;}return false;}int main(){int x,o,cases;scanf("%d",&cases);while(cases--){scanf("%s%s%s",s,&s[3],&s[6]);x=count(s,s+9,'X');o=count(s,s+9,'O');if(x<o||o+1<x)puts("no");else if(x>o&&check('X')&&!check('O')) puts("yes");else if(o==x&&!check('X')&&check('O')) puts("yes");else if(!check('X')&&!check('O')) puts("yes");else puts("no");}return 0;} 

0 0
原创粉丝点击