A concise recursive function - judgment [Mahjong] and card

xiaoxiao2021-03-06  64

/ ************************************************** ************** * File Name: Hu.cpp * * * * Function: Demonstrate a simple recursive function - judgment [Mahjong] and card. * * *: This function does not judge seven pairs and thirteen, readers are not difficult to judge; * * At the same time, due to the different rules of mahjong, please add and modify it yourself. * * * * 2. Other games similar to mahjong, such as [word] (also known as run beard, * * two seventy), etc., you can also use a similar judgment function. * * * * Environment: VC 6.0, but comply with ANSI C standard, casually transplant ^ * * * * author: ShyWorm (afraid) * * E_mail: ShyWorm@sina.com * ****** *********************************************************** ******* / # include int hu (int Pai [38]); int main () {// put a plate below In the array, you can fill in the number to test the function correctly or not.

/ / For convenience, PAI [0], PAI [10], PAI [20], PAI [30] is not used, and must // is set to 0, pay attention! INT PAI [38] = {0, 1, 1, 1, 0, 1, 1, 1, 0, 0, // PAI [1- 9] 万 万 ~ 0, 0, 0, 0 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, / / PAI [21-29] 0, 0, 1, 1, 1, 0, 0, 0 // PAI [31-37] Number of borough in the northwest of southeast China; // Be sure to eliminate "seven pairs" and "thirteen", because it is simple, so no // if (QIdui (PAI)) ... IF (Hu (Hu PAI)) Printf ("Ha! I and A! / N"); Else Printf ("Hey, I don't! / N"); Return 1;} // Judgment and card recursive functions, do not consider "seven pairs" And "thirteen". Because if // puts "seven pairs" and "thirteen" judgment in the recursive function, it will be lost. INT Hu (int Pai [38]) {static int jiang = 0; // will "two" IF in the brand "three three three three two" Return 1; // Recursive exit conditions: If there is no left, then return to the card.

转载请注明原文地址:https://www.9cbs.com/read-89458.html

New Post(0)