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

📄 wuzi.cpp

📁 一个在tc3.0下面写的棋类游戏 很经典 值得好好研究
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	      break;
	   }
     else if(matrix[i][j+count1+1]==0&&matrix[i][j-count2-1]==0)
	   {
	   if(matrix[i][j+count1+2]==0||matrix[i][j-count2-2]==0)
	    { mark.livethree++;
	     lthorf++;    }
	   else
	      mark.crackthree++;
	     break;
	   }

     else if(matrix[i][j+count1+1]!=who&&matrix[i][j-count2-1]!=who)
	   {}
     else
     {
       mark.crackthree++;
       break;
     }
    case 2:
     if(j+count1+1<=15&&j-count2-1>=0)
     {
      if(matrix[i][j+count1+1]==0&&matrix[i][j+count1+2]==who&&matrix[i][j+count1+3]==who
	  ||matrix[i][j-count2-1]==0&&matrix[i][j-count2-2]==who&&matrix[i][j-count2-3]==who)
	  {
	    mark.crackfour++;
	    lthorf++;
	    break;
	   }
      else if(matrix[i][j+count1+1]==0&&matrix[i][j+count1+2]==who&&matrix[i][j+count1+3]==0
	||matrix[i][j-count2-1]==0&&matrix[i][j-count2-2]==who&&matrix[i][j-count2-3]==0)
	 {
	  mark.livethree++;
	   lthorf++;
	  break;
	  }

      else if(matrix[i][j+count1+1]==0&&matrix[i][j-count2-1]==0)
      {
	mark.livetwo++;
	break;
      }
     else  if(matrix[i][j+count1+1]!=who&&matrix[i][j-count2-1]!=who)
       {
       break;
       }
       else
       {
       mark.cracktwo++;
       break;
	}
   }
   case 1:
      mark.one++;
     if(
       matrix[i][j+count1+1]==0&&matrix[i][j+count1+2]==who
	&&matrix[i][j+count1+3]==who&&matrix[i][j+count1+4]==who
	||matrix[i][j-count2-1]==0&&matrix[i][j-count2-2]==who
	&&matrix[i][j-count2-3]==who&&matrix[i][j-count2-4]==who)
	  {
		 mark.crackfour++;
		 mark.one--;
		 lthorf++;
	  }
   else if(matrix[i][j-count2-1]==0&&matrix[i][j+count1+1]==0
       &&matrix[i][j+count1+2]==who&&matrix[i][j+count1+3]==who
       &&matrix[i][j+count1+4]==0
       ||matrix[i][j+count1+1]==0&&matrix[i][j-count2-1]==0
       &&matrix[i][j-count2-2]==who
       &&matrix[i][j-count2-3]==who&&matrix[i][j-count2-4]==0)
	       {
		mark.livethree++;
		mark.one--;
		lthorf++;
	       }

      break;}

   /* line*/
    countcolum=0;
    count1=0;
    count2=0;
    ci=i;
    cj=j;
   while(matrix[ci+1][j]==who)
   {
    count1++;
    ci++;
    if(cj>15)
    break;
   }
   ci=i;
   while(matrix[ci-1][j]==who)
     {
      count2++;
      ci--;
      if(cj<1)
       break;
     }
     countcolum=count1+count2+1;
  switch  (countcolum)
   { case  5:
     mark.five++;
     break;

    case 4:
  //   if(i+count1+1<=15&&i-count2-1>=0)
      if(matrix[i+count1+1][j]==0&&matrix[i-count2-1][j]==0)
	{
		 mark.livefour++;
		 break;
	}
       else if(matrix[i+count1+1][j]==0||matrix[i-count2-1][j]==0)
	{
		mark.crackfour++;
		lthorf++;
		break;
       }
	    else if(matrix[i+count1+1][j]!=who&&matrix[i-count2-1][j]!=who)
	break;

    case 3:
     if((matrix[i+count1+1][j]==0&&matrix[i+count1+2][j]==who)
	||(matrix[i-count2-1][j]==0&&matrix[i-count2-2][j]==who))
	    {
	       mark.crackfour++;
	       lthorf++;
	       break;
	    }
     else if(matrix[i+count1+1][j]==0&&matrix[i-count2-1][j]==0)
	{
	  if(matrix[i+count1+2][j]==0||matrix[i-count2-2][j]==0)
	    { mark.livethree++;
	     lthorf++;}
	  else
	      mark.crackthree++;
	     break;
	}


     else if(matrix[i+count1+1][j]!=who&&matrix[i-count2-1][j]!=who)
	     break;
     else
      {
	     mark.crackthree++;
	     break;
      }
    case 2:
  //   if(i+count1+1<=15&&i-count2-1>=0)
      if((matrix[i+count1+1][j]==0&&matrix[i+count1+2][j]==who
	  &&matrix[i+count1+3][j]==who)
	  ||(matrix[i-count2-1][j]==0&&matrix[i-count2-2][j]==who
	  &&matrix[i-count2-3][j]==who))
		  {
			 mark.crackfour++;
			 lthorf++;
			 break;
		  }
   else if(matrix[i+count1+1][j]==0&&matrix[i+count1+2][j]==who&&matrix[i+count1+3][j]==0
	  ||matrix[i-count2-1][j]==0&&matrix[i-count2-2][j]==who&&matrix[i-count2-3][j]==0)
		 {
			mark.livethree++;
			lthorf++;
		 }

   else if(matrix[i+count1+1][j]==0&&matrix[i-count2-1][j]==0)
      {
	 mark.livetwo++;
	 break;
      }

     else  if(matrix[i+count1+1][j]!=who&&matrix[i-count2-1][j]!=who)
       {
	    break;
       }
       else
       {
	   mark.cracktwo++;
	     break;
	}
   case 1:
	mark.one++;
	if( matrix[i+count1+1][j]==0&&matrix[i+count1+2][j]==who
	  &&matrix[i+count1+3][j]==who&&matrix[i+count1+4][j]==who
	  ||matrix[i-count2-1][j]==0&&matrix[i-count2-2][j]==who
	  &&matrix[i-count2-3][j]==who&&matrix[i-count2-4][j]==who)
	       {
		 mark.crackfour++;
		 mark.one--;
		 lthorf++;
	       }
	if(matrix[i-count2-1][j]==0&&matrix[i+count1+1][j]==0
	  &&matrix[i+count1+2][j]==who&&matrix[i+count1+3][j]==who
	  &&matrix[i+count1+4][j]==0
	  ||matrix[i+count1+1][j]==0&&matrix[i-count2-1][j]==0&&matrix[i-count2-2][j]==who
	  &&matrix[i-count2-3][j]==who&&matrix[i-count2-4][j]==0)
		{
		 mark.livethree++;
		 mark.one--;
		 lthorf++;
		 }
	  break;
      }
	/*left lean*/
   count1=0;
   count2=0;
   ci=i;
   cj=j;
   while(matrix[ci+1][cj+1]==who)
   {
    count1++;
    cj++;
    ci++;
    if((cj>15)||(ci>15))
    break;
   }
   cj=j;
   ci=i;
   while(matrix[ci-1][cj-1]==who)
     {
      count2++;
      cj--;
      ci--;
      if((cj<1)||(ci<1))
       break;
     }
     count=count1+count2+1;
   switch  (count)
   { case  5:
     mark.five++;
     break;

    case 4:
   // if(i+count1+1<=15&&j+count1+1<=15&&i-count2-1>=0&&j-count2-1>=0)

      if(matrix[i+count1+1][j+count1+1]==0&&matrix[i-count2-1][j-count2-1]==0)
	{
	   mark.livefour++;
	   break;
	}
      else if(matrix[i+count1+1][j+count1+1]==0||matrix[i-count2-1][j-count2-1]==0)
	{
	   mark.crackfour++;
	   lthorf++;
	   break;
	}
	 else if(matrix[i+count1+1][j+count1+1]!=who&&matrix[i-count2-1][j-count2-1]!=who)
	   break;



    case 3:
     if((matrix[i+count1+1][j+count1+1]==0&&matrix[i+count1+2][j+count1+2]==who)
	 ||(matrix[i-count2-1][j-count2-1]==0&&matrix[i-count2-2][j-count2-2]==who))
	    {
	       mark.crackfour++;
	       lthorf++;
	       break;
	    }
    else if(matrix[i+count1+1][j+count1+1]==0&&matrix[i-count2-1][j-count2-1]==0)
       {
	if(matrix[i+count1+2][j+count1+2]==0||matrix[i-count2-2][j-count2-2]==0)
	  {
	  mark.livethree++;
	  lthorf++;
	  }
	else
	  mark.crackthree++;
	break;
      }
     else if(matrix[i+count1+1][j+count1+1]!=who&&matrix[i-count2-1][j-count2-1]!=who)
     break;
     else
     {
     mark.crackthree++;
       break;
     }
    case 2:
     if((matrix[i+count1+1][j+count1+1]==0&&matrix[i+count1+2][j+count1+2]==who
	&&matrix[i+count1+3][j+count1+3]==who)
	||(matrix[i-count2-1][j-count2-1]==0&&matrix[i-count2-2][j-count2-2]==who
	&&matrix[i-count2-3][j-count2-3]==who))
		{       mark.crackfour++;
			lthorf++;
			break;
		}
    else if((matrix[i+count1+2][j+count2+2]==who
	    &&matrix[i+count1+3][j+count2+3]==0)
	    ||(matrix[i-count2-2][j-count2-2]==who
	    &&matrix[i-count1-3][j-count2-3]==0))
		{
		       mark.livethree++;
		       lthorf++;
		       break;
		}
    else if(matrix[i+count1+1][j+count1+1]==0&&matrix[i-count2-1][j-count2-1]==0)
      {
	   mark.livetwo++;
	   break;
      }
     else  if(matrix[i+count1+1][j+count1+1]!=who&&matrix[i-count2-1][j-count2-1]!=who)
       {
       break;
       }
       else
       {
	 mark.cracktwo++;
	 break;
	}
   case 1:
      mark.one++;
	  if(matrix[i+1][j+1]==0&&matrix[i+count1+2][j+count1+2]==who
	     &&matrix[i+count1+3][j+count1+3]==who
	     &&matrix[i+count1+4][j+count1+4]==who
	     ||matrix[i-1][j-1]==0&&matrix[i-count2-2][j-count2-2]==who
	     &&matrix[i-count2-3][j-count2-3]==who
	     &&matrix[i-count2-4][j-count2-4]==who)
	      {
		 mark.crackfour++;
		 mark.one--;
		 lthorf++;
		 break;
	      }
	  else if(matrix[i-1][j-1]==0&&matrix[i+1][j+1]==0
	     &&matrix[i+count1+2][j+count1+2]==who
	     &&matrix[i+count1+3][j+count1+3]==who
	     &&matrix[i+count1+4][j+count1+4]==0
	     ||matrix[i+1][j+1]==0&&matrix[i-1][j-1]==0
	     &&matrix[i-count2-2][j-count2-2]==who
	     &&matrix[i-count2-3][j-count2-3]==who
	     &&matrix[i-count2-4][j-count2-4]==0)
		{
		  mark.livethree++;
		  mark.one--;
		  lthorf++;
		  break;
		}
	     break;
      }
	 /*RIGHT LEAN*/
   count1=0;
   count2=0;
   ci=i;
   cj=j;
   while(matrix[ci-1][cj+1]==who)
   {
    count1++;
    cj++;
    ci--;
    if((cj>15)||(ci<1))
    break;
   }
   cj=j;
   ci=i;
   while(matrix[ci+1][cj-1]==who)
     {
      count2++;
      ci++;
      cj--;
      if((cj<1)||(ci>15))
	   break;
     }
     count=count1+count2+1;

     switch  (count)
   { case  5:
     mark.five++;
     break;

    case 4:

     if(matrix[i-count1-1][j+count1+1]==0&&matrix[i+count2+1][j-count2-1]==0)
      {
	mark.livefour++;
	break;
       }
     else if(matrix[i-count1-1][j+count1+1]==0||matrix[i+count2+1][j-count2-1]==0)
       {
	mark.crackfour++;
	lthorf++;
	break;
       }
     else if(matrix[i-count1-1][j+count1+1]!=who&&matrix[i+count2+1][j-count2-1]!=who)
       break;

    case 3:
    if(matrix[i-count1-1][j+count1+1]==0&&matrix[i-count1-2][j+count1+2]==who
    ||matrix[i+count2+1][j-count2-1]==0&&matrix[i+count2+2][j-count2-2]==who)
	     {
		mark.crackfour++;
		lthorf++;
		break;
	     }

    else if(matrix[i-count1-1][j+count1+1]==0&&matrix[i+count2+1][j-count2-1]==0)
       {
	  if(matrix[i-count1-2][j+count1+2]==0||matrix[i+count2+2][j-count2-2]==0)
	  {
	    mark.livethree++;
	     lthorf++;
	   }
	   else
	   mark.crackthree++;
	break;
	}
     else if(matrix[i-count1-1][j+count1+1]!=-who&&matrix[i+count2+1][j-count2-1]!=-who)
     break;
     else
     { mark.crackthree++;
       break;
     }
    case 2:
       if((matrix[i-count1-1][j+count1+1]==0&&matrix[i-count1-2][j+count1+2]==who
	  &&matrix[i-count1-3][j+count1+3]==who)
	  ||(matrix[i+count2+1][j-count2-1]==0&&matrix[i+count2+2][j-count2-2]==who
	  &&matrix[i+count2+3][j-count2-3]==who))
		{
		 mark.crackfour++;
		 lthorf++;
		 break;
		}
   else if(matrix[i-count1-2][j+count1+2]==who
	  &&matrix[i-count1-3][j+count1+3]==0
	  ||matrix[i+count2+2][j-count2-2]==who
	  &&matrix[i+count2+3][j-count2-3]==0)
	     {  mark.livethree++;
		lthorf++;
		break;
	     }

   else if(matrix[i-count1-1][j+count1+1]==0&&matrix[i+count2+1][j-count2-1]==0)
      {
       mark.livetwo++;
	break;
      }
     else  if(matrix[i-count1-1][j+count1+1]!=who&&matrix[i+count2+1][j-count2-1]!=who)
       {
       break;
       }
       else
       {   mark.cracktwo++;
	    break;
	}
   case 1:
      mark.one++;
	   if(matrix[i+count2+1][j-count2-1]==0
	     &&matrix[i-count1-1][j+count1+1]==0
	     &&matrix[i-count1-2][j+count1+2]==who
	     &&matrix[i-count1-3][j+count1+3]==who
	     &&matrix[i-count1-4][j+count1+4]==who
	     ||matrix[i-count1-1][j+count1+1]==0
	     &&matrix[i+count2+1][j-count2-1]==0
	     &&matrix[i+count2+2][j-count2-2]==who
	     &&matrix[i+count2+3][j-count2-3]==who
	     &&matrix[i+count2+4][j-count2-4]==who)
	       {
		 mark.crackfour++;

⌨️ 快捷键说明

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