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

📄 win.cs

📁 visual c# 网络编程技术与实践实例包括几个源码
💻 CS
字号:
using System;

namespace 五子棋
{
	/// <summary>
	/// IsWin 的摘要说明。
	/// </summary>
	public class Win
	{
		int[,] pos;
		public Win(int[,]p)
		{
			pos=p;
		}
		public int winchess( int cellx,int celly)
		{
			for(int i=0;i<5;i++)
			{
				int xtotal=Wfive(cellx-i,celly);
                if(Math.Abs(xtotal)==5) 
                    return xtotal;
				int ytotal=Hfive(cellx,celly-i);
                if(Math.Abs(ytotal)==5)
                    return ytotal;
				int xytotal=Piefive(cellx+i,celly-i);
                if(Math.Abs(xytotal)==5) 
                    return xytotal;
				xytotal=Lafive(cellx-i,celly-i);
                if(Math.Abs(xytotal)==5) 
                    return xytotal;
			}
			
			return 0;
		}
		private int Wfive(int xbegin,int y)
		{
			int total=0;
			for(int i=0;i<5;i++)
			{
				try
				{
					total=total+pos[xbegin+i,y];
				}
				catch
				{
					return 0;
				}
			}
			return total;
		}
		private int Hfive(int x,int ybegin)
		{
			int total=0;
			for(int i=0;i<5;i++)
			{
				try
				{
					total=total+pos[x,ybegin+i];
				}
				catch
				{
					return 0;
				}
			}
			return total;
		}
		private int Piefive(int x,int y)
		{
			int total=0;
			for(int i=0;i<5;i++)
			{
				try
				{
					total=total+pos[x-i,y+i];
				}
				catch
				{
					return 0;
				}
			}
			return total;
		}
		private int Lafive(int x,int y)
		{
			int total=0;
			for(int i=0;i<5;i++)
			{
				try
				{
					total=total+pos[x+i,y+i];
				}
				catch
				{
					return 0;
				}
			}
			return total;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -