Demo entry 6686239

123

   

Submitted by anonymous on Dec 22, 2017 at 19:07
Language: C++. Code size: 449 Bytes.

int canput(int row,int col)                          //能否放置 
{
	int i,j;
	for(i=0;i<N;i++)								
	{
		if (chess[i][col]==1)                     	//第i行已经放置棋子,则不能放置
		{
			return 0;							
		}
		for(j=0;j<N;j++)							
		{
			if(chess[row][j]==1) 					//第j列已经放置棋子,则不能放置
			{
				return 0;
			}
			if((chess[i][j]==1)&&(((i-row)==(j-col))||((i-row)==(col-j))))    //chess[i][j]已经放置棋子,则主对角线和副对角线上不能放置
			{
				return 0;
			}
		}
	}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).