⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 win.cpp

📁 这个主要是我学习数据结构的课程设计的程序
💻 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 + -