#include <iostream> #include <iomanip> using namespace std; int row=16; int col=16; int all[17][17]; bool black=true; bool whilt; int x,y; int a=1; int t=0; bool win(){ for(int i=1;i<=16;i++){ if(all[i][a]==1){ t++; if(t==5){ return true; } } a++; } return false; } void f5(){ cout<<" "; for(int j=1;j<=col;j++){ cout<<setw(3)<<j; } cout<<endl; for(int i=1;i<=row;i++){ cout<<setw(2)<<i; for(int j=1;j<=col;j++){ if(all[i][j]==0){ cout<<setw(3)<<"."; }else if(all[i][j]==1){ cout<<setw(3)<<"黑"; }else{ cout<<setw(3)<<"白"; } } cout<<endl; } } int main(int argc, char** argv) { for(int i=0;i<17;i++){ for(int j=0;j<17;j++){ all[i][j]=0; } } while(true){ system("cls"); f5(); if(black){ cout<<"黑棋请落子:"; cin>>x>>y; if(x>16||y>16||all[x][y]!=0){ continue; } all[x][y]=1; black=false; }else{ cout<<"白棋请落子:"; cin>>x>>y; if(x>16||y>16||all[x][y]!=0){ continue; } all[x][y]=2; black=true; } } return 0; }
标签:17,16,int,五子棋,black,bool From: https://www.cnblogs.com/As10016/p/17623499.html