?? win.cpp
字號:
// Win.cpp: implementation of the Win class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Five.h"
#include "Win.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Win::Win()
{
this->init();
}
Win::~Win()
{
}
void Win::init()
{
for(int i=1;i<=14;i++)
for(int j=1;j<=14;j++)
chess[i][j]=0;
}
int Win::win(int x, int y)
{
const int cc[4][2]={ 0, 1,
1, 1,
1, 0,
1, -1};
const int dd[4][2]={ 0, -1,
-1, -1,
-1, 0,
-1, 1};
int s,s1,s2,x1,y1;
for(int i=0;i<4;i++)
{
s=chess[x][y];
s1=chess[x][y];
s2=chess[x][y];
x1=x;
y1=y;
x1+=cc[i][0];
y1+=cc[i][1];
while(chess[x1][y1]==s)
{
if(((x1>=1)&&(x1<=14))&&((y1>=1)&&(y1<=14)))
{
s1+=chess[x1][y1];
x1+=cc[i][0];
y1+=cc[i][1];
}
else
break;
}
x1=x;
y1=y;
x1+=dd[i][0];
y1+=dd[i][1];
while(chess[x1][y1]==s)
{
if(((x1>=1)&&(x1<=14))&&((y1>=1)&&(y1<=14)))
{
s2+=chess[x1][y1];
x1+=dd[i][0];
y1+=dd[i][1];
}
else
break;
}
if((s1+s2)>=6 && (s1+s2)<=14) return 1;
if((s1+s2)>=60) return 2;
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -