-
个人简介
马晨轩是我的神
井字琪游戏
人和机器下人和人下 先后自己定 每次输入2个数 第1个数是行 第2个数是列 go on=继续 the match ended in a draw=平局#include<bits/stdc++.h> using namespace std; long long x,y,s,s1,t,a[5][5]; bool p,p1; int main() { while(true) { cin>>x>>y; t++; if(t%2==0) a[x][y]=2; else a[x][y]=1; for(int i=1;i<=3;i++) { s=0; s1=0; for(int j=1;j<=3;j++) if(a[i][j]==2) s++; else if(a[i][j]==1) s1++; if(s==3) { cout<<"2 win"; return 0; } else if(s1==3) { cout<<"1 win"; return 0; } } s=0; s1=0; for(int i=1;i<=3;i++) { s=0; s1=0; for(int j=1;j<=3;j++) if(a[j][i]==2) s++; else if(a[j][i]==1) s1++; if(s==3) { cout<<"2 win"; return 0; } else if(s1==3) { cout<<"1 win"; return 0; } } if(a[1][1]==1&&a[2][2]==1&&a[3][3]==1||a[1][3]==1&&a[2][2]==1&&a[3][1]==1) { cout<<"1 win"; return 0; } if(a[1][1]==2&&a[2][2]==2&&a[3][3]==2||a[1][3]==2&&a[2][2]==2&&a[3][1]==2) { cout<<"2 win"; return 0; } p1=false; for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) if(a[i][j]==0) { p1=true; cout<<"go on"<<endl; break; } if(p1==false) { cout<<"the match ended in a draw"; return 0; } for(int i=1;i<=3;i++) { for(int j=1;j<=3;j++) cout<<a[i][j]<<' '; cout<<endl; } } }
亿些有趣的网站
学术区:
灌水区:
工具区:
$\boxed{\text{油猴上好用的代码——洛谷版 ∽ 有安装油猴的必装,可以增强使用洛谷的体验感!}}$
其它区:
-
通过的题目
-
最近活动
This person is lazy and didn't join any contests or homework. -
最近编写的题解
题目标签
- 聪明人游戏
- 4
- 深搜 广搜
- 1
- 广搜
- 1
- 大沥2021
- 1