#include <iostream>
#include <iomanip>
using namespace std;
int row=16;
int col=16;
bool black=true;
int all[17][17];
void F5(){
    for(int ii=0;ii<=col;ii++){
        cout<<setw(3)<<ii;
    }
    cout<<endl;
    for(int i=0;i<row;i++){
        cout<<setw(3)<<i+1;
        for(int j=0;j<col;j++){
            if(all[i][j]==0){
                cout<<setw(3)<<".";
            }else if(all[i][j]==1){
                cout<<setw(3)<<"";
            }else if(all[i][j]==2){
                cout<<setw(3)<<"";
            }
        }
        cout<<endl;
    }
}
int main(){
    int x,y;
    while(1){
        system("cls");
        F5();
        if(black){
            cout<<"黑棋请落子"; 
            cin>>x>>y;
            if(all[x-1][y-1]!=0||x<0||y<0||x>16||y>16){
                continue;
            }
            all[x-1][y-1]=1;
            black=false;
            if(all[x+1][y]==1||all[x+2][y]==1||all[x+3][y]==1||all[x+4][y]==1){
                cout<<"win";
            }else if(all[x-1][y]==1||all[x-2][y]==1||all[x-3][y]==1||all[x-4][y]==1){
                cout<<"win";
            }else if(all[x+1][y]==1||all[x+2][y]==1||all[x+3][y]==1||all[x-1][y]==1){
                cout<<"win";
            }else if(all[x+1][y]==1||all[x+2][y]==1||all[x-2][y]==1||all[x-1][y]==1){
                cout<<"win";
            }else if(all[x+1][y]==1||all[x-3][y]==1||all[x-2][y]==1||all[x-1][y]==1){
                cout<<"win";
            }else if(all[x][y+1]==1||all[x][y+2]==1||all[x][y+3]==1||all[x][y+4]==1){
                cout<<"win";
            }else if(all[x][y+1]==1||all[x][y+2]==1||all[x][y+3]==1||all[x][y-1]==1){
                cout<<"win";
            }else if(all[x][y+1]==1||all[x][y+2]==1||all[x][y-2]==1||all[x][y-1]==1){
                cout<<"win";
            }else if(all[x][y+1]==1||all[x][y-1]==1||all[x][y-2]==1||all[x][y-3]==1){
                cout<<"win";
            }else if(all[x][y-1]==1||all[x][y-2]==1||all[x][y-3]==1||all[x][y-4]==1){
                cout<<"win";
            }else if(all[x+1][y+1]==1||all[x+2][y+2]==1||all[x+3][y+3]==1||all[x+4][y+4]==1){
                cout<<"win";
            }else if(all[x-1][y-1]==1||all[x-2][y-2]==1||all[x-3][y-3]==1||all[x-4][y-4]==1){
                cout<<"win";
            }else if(all[x+1][y+1]==1||all[x+2][y+2]==1||all[x+3][y+3]==1||all[x-1][y-1]==1){
                cout<<"win";
            }else if(all[x+1][y+1]==1||all[x+2][y+2]==1||all[x-2][y-2]==1||all[x-1][y-1]==1){
                cout<<"win";
            }else if(all[x+1][y+1]==1||all[x-3][y-3]==1||all[x-2][y-2]==1||all[x-1][y-1]==1){
                cout<<"win";
            }else if(all[x-1][y+1]==1||all[x-2][y+2]==1||all[x-3][y+3]==1||all[x-4][y+4]==1){
                cout<<"win";
            }else if(all[x-1][y+1]==1||all[x-2][y+2]==1||all[x-3][y+3]==1||all[x+1][y-1]==1){
                cout<<"win";
            }else if(all[x-1][y+1]==1||all[x-2][y+2]==1||all[x+2][y-2]==1||all[x+1][y-1]==1){
                cout<<"win";
            }else if(all[x-1][y+1]==1||all[x+1][y-1]==1||all[x+2][y-2]==1||all[x+3][y-3]==1){
                cout<<"win";
            }else if(all[x+1][y-1]==1||all[x+2][y-2]==1||all[x+3][y-3]==1||all[x+4][y-4]==1){
                cout<<"win";
            }
        }else{
            cout<<"白棋请落子";
            cin>>x>>y;
            if(all[x-1][y-1]!=0||x<0||y<0||x>16||y>16){
                continue;
            }
            all[x-1][y-1]=2;
            black=true;
        }
    }
    return 0;
}

 

posted on 2023-11-05 09:33  爱吃泡面的皮卡  阅读(5)  评论(0编辑  收藏  举报