1 条评论

  • @ 2026-7-8 15:24:52
    #include<bits/stdc++.h>
    using namespace std;
    int A=0,B=0;
    char a='x',s[110][110];
    int main(){
    	while(1>0){
    		while(1>0){
    			int n,m;
    			for(int i=1;i<=3;i++){
    				for(int j=1;j<=3;j++){
    					cout<<s[i][j]<<" ";
    				}
    				cout<<'\n';
    			}
    			cin>>n>>m;
    			s[n][m]=a;
    			if(a=='x'){
    				a='o';
    			}else{
    				a='x';
    			}
    			if(s[1][1]=='x'&&s[1][2]=='x'&&s[1][3]=='x'||s[1][1]=='x'&&s[2][1]=='x'&&s[3][1]=='x'||s[1][1]=='x'&&s[2][2]=='x'&&s[3][3]=='x'){
    				A++;
    				cout<<"B方胜利!"<<endl<<A<<":"<<B<<endl<<"下一盘游戏开始"<<endl;
    				for(int i=1;i<=3;i++){
    					for(int j=1;j<=3;j++){
    						s[i][j]='0';
    					}
    				}
    				break;
    			}else if(s[3][1]=='x'&&s[3][2]=='x'&&s[3][3]=='x'||s[1][3]=='x'&&s[2][3]=='x'&&s[3][3]=='x'||s[3][1]=='x'&&s[2][2]=='x'&&s[1][3]=='x'){
    				A++;
    				cout<<"B方胜利!"<<endl<<A<<":"<<B<<endl<<"下一盘游戏开始"<<endl;
    				for(int i=1;i<=3;i++){
    					for(int j=1;j<=3;j++){
    						s[i][j]='0';
    					}
    				}
    				break;
    			}else if(s[1][2]=='x'&&s[2][2]=='x'&&s[3][2]=='x'||s[2][1]=='x'&&s[2][2]=='x'&&s[2][3]=='x'){
    				A++;
    				cout<<"B方胜利!"<<endl<<A<<":"<<B<<endl<<"下一盘游戏开始"<<endl;
    				for(int i=1;i<=3;i++){
    					for(int j=1;j<=3;j++){
    						s[i][j]='0';
    					}
    				}
    				break;
    			}else if(s[1][1]=='o'&&s[1][2]=='o'&&s[1][3]=='o'||s[1][1]=='o'&&s[2][1]=='o'&&s[3][1]=='o'||s[1][1]=='o'&&s[2][2]=='o'&&s[3][3]=='o'){
    				A++;
    				cout<<"B方胜利!"<<endl<<A<<":"<<B<<endl<<"下一盘游戏开始"<<endl;
    				for(int i=1;i<=3;i++){
    					for(int j=1;j<=3;j++){
    						s[i][j]='0';
    					}
    				}
    				break;
    			}else if(s[3][1]=='o'&&s[3][2]=='o'&&s[3][3]=='o'||s[1][3]=='o'&&s[2][3]=='o'&&s[3][3]=='o'||s[3][1]=='o'&&s[2][2]=='o'&&s[1][3]=='o'){
    				A++;
    				cout<<"B方胜利!"<<endl<<A<<":"<<B<<endl<<"下一盘游戏开始"<<endl;
    				for(int i=1;i<=3;i++){
    					for(int j=1;j<=3;j++){
    						s[i][j]='0';
    					}
    				}
    				break;
    			}else if(s[1][2]=='o'&&s[2][2]=='o'&&s[3][2]=='o'||s[2][1]=='o'&&s[2][2]=='o'&&s[2][3]=='o'){
    				B++;
    				cout<<"B方胜利!"<<endl<<A<<":"<<B<<endl<<"下一盘游戏开始"<<endl;
    				for(int i=1;i<=3;i++){
    					for(int j=1;j<=3;j++){
    						s[i][j]='0';
    					}
    				}
    				break;
    			}
    		}
    	}
    	
    	return 0;
    }
    
  • 1

信息

ID
68
时间
1000ms
内存
256MiB
难度
9
标签
递交数
60
已通过
7
上传者