#include <bits/stdc++.h> using namespace std; int ROW = 16,COL = 16; bool a = true,player1[16][16],player2[16][16],a1; int Player[16][16] = {0}; void f5(){ for(int i = 0;i<=COL;i++){ cout<<setw(3)<<i; } cout<<endl; for(int i = 0;i<ROW;i++){ cout<<setw(3)<<i+1; for(int j = 0;j<COL;j++){ if(Player[i][j]==0){ cout<<setw(3)<<"."; }else if(Player[i][j]==1){ cout<<setw(3)<<"黑"; }else if(Player[i][j]==2){ cout<<setw(3)<<"白"; } } cout<<endl; } } bool player1_win(){ for(int i = 0;i<ROW;i++){ for(int j = 0;j<COL;j++){ if(Player[i][j]==1){ a = true; for(int w = 1;w<5;w++){ if(Player[i+w][j]!=1 || Player[i-w][j]!=1){ a = false; } } } } } } void player2_win(){ } int main() { int x,y; while(1){ system("cls"); f5(); if(a){ cout<<"黑棋请落子:"; cin>>x>>y; if(Player[x-1][y-1]!=0 || x<=0 || y<=0 || x>ROW || y>COL){ continue; } a = false; Player[x-1][y-1] = 1; player1[x-1][y-1] = true; if(a1){ cout<<"黑棋胜利"; break; } }else{ cout<<"白棋请落子:"; cin>>x>>y; if(Player[x-1][y-1]!=0 || x<=0 || y<=0 || x>ROW || y>COL){ continue; } a = true; Player[x-1][y-1] = 2; player2[x-1][y-1] = true; } } return 0; }
标签:16,int,五子棋,Player,true,COL From: https://www.cnblogs.com/wangyihang-xh/p/17621454.html