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

📄 suoha_algri.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
         p_Cards[4]=14;
         c_Cards[0]=21;
         c_Cards[1]=15;
         c_Cards[2]=35;
         c_Cards[3]=45;
         c_Cards[4]=25;
         break;
      case 5:
         p_Cards[0]=10;
         p_Cards[1]=11;
         p_Cards[2]=14;
         p_Cards[3]=34;
         p_Cards[4]=15;
         c_Cards[0]=21;
         c_Cards[1]=22;
         c_Cards[2]=35;
         c_Cards[3]=45;
         c_Cards[4]=25;
         break;
      case 6:
         p_Cards[0]=10;
         p_Cards[1]=11;
         p_Cards[2]=14;
         p_Cards[3]=34;
         p_Cards[4]=15;
         c_Cards[0]=21;
         c_Cards[1]=22;
         c_Cards[2]=32;
         c_Cards[3]=42;
         c_Cards[4]=12;
         break;
      case 7:
         p_Cards[0]=10;
         p_Cards[1]=24;
         p_Cards[2]=14;
         p_Cards[3]=34;
         p_Cards[4]=15;
         c_Cards[0]=21;
         c_Cards[1]=22;
         c_Cards[2]=33;
         c_Cards[3]=44;
         c_Cards[4]=11;
         break;
      case 8:
         p_Cards[0]=10;
         p_Cards[1]=24;
         p_Cards[2]=14;
         p_Cards[3]=34;
         p_Cards[4]=15;
         c_Cards[0]=21;
         c_Cards[1]=22;
         c_Cards[2]=33;
         c_Cards[3]=44;
         c_Cards[4]=13;
         break;
      case 9:
         p_Cards[0]=10;
         p_Cards[1]=24;
         p_Cards[2]=14;
         p_Cards[3]=34;
         p_Cards[4]=15;
         c_Cards[0]=21;
         c_Cards[1]=22;
         c_Cards[2]=33;
         c_Cards[3]=43;
         c_Cards[4]=13;
         break;
      case 10:
         p_Cards[0]=10;
         p_Cards[1]=24;
         p_Cards[2]=14;
         p_Cards[3]=34;
         p_Cards[4]=15;
         c_Cards[0]=21;
         c_Cards[1]=22;
         c_Cards[2]=32;
         c_Cards[3]=42;
         c_Cards[4]=12;
         break;
      case 11:
         p_Cards[0]=10;
         p_Cards[1]=24;
         p_Cards[2]=14;
         p_Cards[3]=34;
         p_Cards[4]=44;
         c_Cards[0]=21;
         c_Cards[1]=22;
         c_Cards[2]=32;
         c_Cards[3]=42;
         c_Cards[4]=12;
         break;
      case 12:
         p_Cards[0]=10;
         p_Cards[1]=24;
         p_Cards[2]=14;
         p_Cards[3]=34;
         p_Cards[4]=44;
         c_Cards[0]=21;
         c_Cards[1]=22;
         c_Cards[2]=15;
         c_Cards[3]=45;
         c_Cards[4]=11;
         break;
      case 13:
         p_Cards[0]=10;
         p_Cards[1]=24;
         p_Cards[2]=14;
         p_Cards[3]=34;
         p_Cards[4]=44;
         c_Cards[0]=21;
         c_Cards[1]=25;
         c_Cards[2]=15;
         c_Cards[3]=45;
         c_Cards[4]=11;
         break;
      case 14:
         p_Cards[0]=10;
         p_Cards[1]=24;
         p_Cards[2]=14;
         p_Cards[3]=34;
         p_Cards[4]=44;
         c_Cards[0]=21;
         c_Cards[1]=25;
         c_Cards[2]=15;
         c_Cards[3]=45;
         c_Cards[4]=35;
         break;
      case 15:
         c_Cards[0]=10;
         c_Cards[1]=11;
         c_Cards[2]=12;
         c_Cards[3]=13;
         c_Cards[4]=14;
         p_Cards[0]=21;
         p_Cards[1]=25;
         p_Cards[2]=15;
         p_Cards[3]=45;
         p_Cards[4]=35;
         break;
      case 16:
         p_Cards[0]=10;
         p_Cards[1]=11;
         p_Cards[2]=12;
         p_Cards[3]=13;
         p_Cards[4]=14;
         c_Cards[0]=21;
         c_Cards[1]=25;
         c_Cards[2]=15;
         c_Cards[3]=45;
         c_Cards[4]=35;
         break;
        default:break;
      }*/
   Set_Suohadifficulty();

}

//4 返回牌的大小
unsigned short FirstNum(unsigned short onecard)
{
   return onecard-(onecard/10)*10;
}

//4 返回牌的花色
unsigned short SecondNum(unsigned short onecard)
{
   return onecard/10;
}

/*********************************************************************************************************
    This module is used to get all kinds of card types under the conditions of two, three, four,or five cards
    Input two cards,three cards, four cards and five cards, and their previous card type
    Output their card type
    Notice: to get n cards of card type, you must input n-1 cards of card type!
**********************************************************************************************************/
CardType Status_Two(unsigned short *whoCards)
{
   CardType pc_Ct;



   if (FirstNum(whoCards[0])==FirstNum(whoCards[1]))
   {
      if (SecondNum(whoCards[0])<SecondNum(whoCards[1]))
         pc_Ct.bigcard = whoCards[1];
      else
         pc_Ct.bigcard = whoCards[0];
      pc_Ct.cardType = TWO_DUIZI;
      return pc_Ct;
   } else
   {
      if (FirstNum(whoCards[0])<FirstNum(whoCards[1]))
         pc_Ct.bigcard = whoCards[1];
      else
         pc_Ct.bigcard = whoCards[0];
      pc_Ct.cardType = TWO_SHANPAI;
      return pc_Ct;
   }
}
//the argument of twoStatus must be return from the funtion of Status_Two
CardType Status_Three(CardType twoStatus, unsigned short *whoCards)
{

   CardType pc_Ct;
   pc_Ct.bigcard =0;
   pc_Ct.cardType =0;
   pc_Ct.smallcard =0;


   switch (twoStatus.cardType)
   {
   case TWO_DUIZI:
      if (FirstNum(whoCards[2])==FirstNum(whoCards[0]))
      {
         pc_Ct.bigcard = whoCards[0];
         pc_Ct.cardType = THREE_SHANTIAO;
         return pc_Ct;
      } else
      {
         pc_Ct.bigcard = twoStatus.bigcard;
         pc_Ct.smallcard=whoCards[0];  //tangyan 1227
         pc_Ct.cardType = THREE_DUIZI;
         return pc_Ct;
      }
      break;
   case TWO_SHANPAI:
      if (FirstNum(whoCards[2])==FirstNum(whoCards[0]) )
      {
         if (SecondNum(whoCards[0])<SecondNum(whoCards[2]))
            pc_Ct.bigcard = whoCards[2];
         else
            pc_Ct.bigcard = whoCards[0];
         pc_Ct.cardType = THREE_DUIZI;
         return pc_Ct;
      } else if (FirstNum(whoCards[2])==FirstNum(whoCards[1]))
      {
         if (SecondNum(whoCards[1])<SecondNum(whoCards[2]))
            pc_Ct.bigcard = whoCards[2];
         else
            pc_Ct.bigcard = whoCards[1];
         pc_Ct.cardType = THREE_DUIZI;
         return pc_Ct;
      } else
      {
         if (FirstNum(twoStatus.bigcard)<FirstNum(whoCards[2]))
            pc_Ct.bigcard = whoCards[2];
         else
            pc_Ct.bigcard = twoStatus.bigcard;
         pc_Ct.cardType = THREE_SHANPAI;
         return pc_Ct;
      }
      break;
   }
   return pc_Ct;
}
//the argument of threeStatus must be return from the funtion of Status_Three
CardType Status_Four(CardType threeStatus, unsigned short *whoCards)
{


   int i, samenum=0, tempcard;
   CardType pc_Ct;
   pc_Ct.bigcard =0;
   pc_Ct.cardType =0;
   pc_Ct.smallcard =0;

   switch (threeStatus.cardType)
   {
   case THREE_SHANTIAO:
      if (FirstNum(whoCards[3])==FirstNum(whoCards[0]))
      {
         pc_Ct.bigcard = whoCards[3];
         pc_Ct.cardType = FOUR_TIEZI;
         return pc_Ct;
      } else
      {
         pc_Ct.bigcard = threeStatus.bigcard;
         pc_Ct.cardType = FOUR_SHANTIAO;
         return pc_Ct;
      }
      break;
   case THREE_DUIZI:
      for (i=0; i<=2; i++)
      {
         if (FirstNum(whoCards[3])==FirstNum(whoCards[i]))
         {
            tempcard = whoCards[i]; 
            samenum++;
         }
      }
      if (samenum==2) //the last card is the same as one card of duizi
      {
         pc_Ct.bigcard = whoCards[3];
         pc_Ct.cardType = FOUR_SHANTIAO;
         return pc_Ct;
      } else if (samenum==1)// total four cards become liangdui
      {
         if (FirstNum(whoCards[3])<FirstNum(threeStatus.bigcard))
         {
            pc_Ct.bigcard = threeStatus.bigcard;
            pc_Ct.smallcard = whoCards[3];
         } else
         {
            if (SecondNum(whoCards[3])>SecondNum(tempcard))
               pc_Ct.bigcard =whoCards[3];
            else
               pc_Ct.bigcard = tempcard;
            pc_Ct.smallcard = threeStatus.bigcard;
         }
         pc_Ct.cardType = FOUR_LIANGDUI;
         return pc_Ct;
      } else
      {
         pc_Ct.bigcard = threeStatus.bigcard;
         pc_Ct.cardType = FOUR_DUIZI;
         return pc_Ct;
      }
      break;
   case THREE_SHANPAI:
      for (i=0; i<=2; i++)
      {
         if (FirstNum(whoCards[3])==FirstNum(whoCards[i]))
         {
            if (SecondNum(whoCards[3])<SecondNum(whoCards[i]))
               pc_Ct.bigcard = whoCards[i];
            else
               pc_Ct.bigcard = whoCards[3];
            samenum++;
         }
      }
      if (samenum==1)
      {
         pc_Ct.cardType = FOUR_DUIZI;
         return pc_Ct;
      } else
      {
         if (FirstNum(threeStatus.bigcard)<FirstNum(whoCards[3]))
            pc_Ct.bigcard = whoCards[3];
         else
            pc_Ct.bigcard = threeStatus.bigcard;
         pc_Ct.cardType = FOUR_SHANPAI;
         return pc_Ct;
      }
      break;

   }
   return pc_Ct;
}

//the argument of fourStatus must be return from the funtion of Status_Four
CardType Status_Five(CardType fourStatus, unsigned short* whoCards)
{
   int i, diff=0, samenum=0, same = 0;
   CardType CT_shanpaiclass, pc_Ct;
   pc_Ct.bigcard =0;
   pc_Ct.cardType =0;
   pc_Ct.smallcard =0;

   switch (fourStatus.cardType)
   {
   case FOUR_TIEZI:
      pc_Ct.cardType = TIEZI;
      pc_Ct.bigcard = whoCards[0];
      return pc_Ct;
      break;
   case FOUR_SHANTIAO:
      for (i=0; i<=3; i++)
      {
         if (FirstNum(whoCards[4])==FirstNum(whoCards[i]))
            samenum++;
         else
            diff = whoCards[i];
      }
      if (samenum==3)
      {
         pc_Ct.cardType = TIEZI;
         pc_Ct.bigcard = whoCards[4];
         return pc_Ct;
      } else if (samenum==1)
      {
         pc_Ct.cardType = HULU;
         pc_Ct.bigcard = diff;
         return pc_Ct;
      } else
      {
         pc_Ct.cardType = SHANTIAO;
         pc_Ct.bigcard = fourStatus.bigcard;
         return pc_Ct;
      }
      break;

   case FOUR_LIANGDUI:
      for (i=0; i<=3; i++)
      {
         if (FirstNum(whoCards[4])==FirstNum(whoCards[i]))
            samenum++;
      }
      if (samenum==2)
      {
         pc_Ct.cardType = HULU;
         pc_Ct.bigcard = whoCards[4];
         return pc_Ct;
      } else
      {
         pc_Ct.cardType = LIANGDUI;
         pc_Ct.bigcard = fourStatus.bigcard;
         pc_Ct.smallcard = fourStatus.smallcard;
         return pc_Ct;
      }
      break;

⌨️ 快捷键说明

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