************************************************************** C++语言五子棋源程序
* 南阳理工学院计算机系01612班大鹏课程设计作品
* 运行环境:TC3.0 (vc6.0不支持画图函数,无法画出棋盘和棋子)
* Email:
[email protected] ************************************************************* #include
#include
#include
#include
#define backcolor CYAN
#define defaultcolor BLACK
#define linecolor MAGENTA
#define player1_color RED
#define player2_color WHITE
#define error_color RED
#define winner_color RED
const int left=40;
const int top=390;
const int d=30;
const int line_num=9;
const int turn=0;
const int r=d/3;
const int j=10;
int x,y,k=1,step=(line_num+1)*(line_num+1);
union REGS regs1,regs2;
class player1;
class player2;
class qipan{
public:
qipan();
~qipan(){};
void init_qipan();
friend void fall(player1 &num1,player2 &num2,qipan &num);
friend void input(player1 &num1,player2 &num2,qipan &num);
private:
int point[line_num+1][line_num+1];
};
class player1{
public:
player1();
~player1(){};
friend void fall(player1 &num1,player2 &num2,qipan &num);
friend void input(player1 &num1,player2 &num2);
friend int judge_winner(player1 &num1,player2 &num2);
private:
int point1[line_num+1][line_num+1];
};
class player2{
public:
player2();
~player2(){};
friend void fall(player1 &num1,player2 &num2,qipan &num);
friend void input(player1 &num1,player2 &num2,qipan &num);
friend int judge_winner(player1 &num1,player2 &num2);
private:
int point2[line_num+1][line_num+1];
};
void input(player1 &num1,player2 &num2);
void fall(player1 &num1,player2 &num2,qipan &num);
int judge_winner(qipan &num,player1 &num1,player2 &num2);
void inputerror();
void display_winner(int);
void main()
{
int driver=DETECT,mode;
initgraph(&driver,&mode,"e:\tc30\bgi");
qipan num;
player1 num1;
player2 num2;
while(step--)
{
input(num1,num2,num);
fall(num1,num2,num);
if(judge_winner(num1,num2))
{
display_winner(k);
}
}
// getchar();
}
qipan::qipan(void)
{ int j,i;
char ch[2]="0";
setbkcolor(backcolor);
setcolor(linecolor);
for(i=0;i
本文地址:http://com.8s8s.com/it/it28452.htm