#include
//#include"data.h"#define N 10//棋盘规格using namespace std;static int chessboard[N][N];//棋盘struct chess{//棋子 int x,y; int color;//0为无子,1为白,-1为黑};void init_chessboard()//初始化棋盘函数;{ int i,j; for(i=0;i<N;i++) for(j=0;j<N;j++) { chessboard[i][j]=0; }}bool is_win(struct chess che)//判断胜负函数,ture 未分出胜负,可以继续下棋;false分出胜负{ int x,y,num; int xmin,xmax,ymin,ymax,min,max; //begin判断左右方向 num=0; xmin=(che.y-4>0)?che.y-4:0;//左边界 xmax=(che.y+4<N-1)?che.y+4:N-1;//右边界 //cout<<xmin<<“左右”<<xmax<<endl; for(y=xmin;y<=xmax;y++) { if(chessboard[che.x][y]che.color&&num<5) { num++; //cout<<num<<endl; if(num5) return false; } else num=0; } //end 判断左右方向 //begin判断上下方向 num=0; ymin=(che.x-4>0)?che.x-4:0;//上边界 ymax=(che.x+4<N-1)?che.x+4:N-1;//下边界 //cout<<ymin<<“上下”<<ymax<<endl; fo
五子棋
最新推荐文章于 2024-05-04 10:24:31 发布