相关代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 BOOL isHuPai(vector<temp1>& pai) 2 { 3 if(tempvec.size()%3 != 2) // 4 return false; 5 6 if(pai.empty()) 7 return false; 8 else 9 { 10 int i; 11 // duizi 11, 22, 33 ,... 12 if(!duizi) 13 { 14 for(i = 1; i < pai.size(); i++) 15 { 16 if(pai[i].index == pai[i-1].index && (pai[i].duizi && pai[i-1].duizi)) 17 { 18 MarkDuizi(tempvec, pai[i-1].index); 19 DeleteNum(pai, pai[i-1].index); 20 MairkDuizi(tempvec, pai[i-1].index); 21 DeleteNum(pai, pai[i-1].index); 22 duizi = TRUE; 23 break; 24 } 25 } 26 } 27 28 // 3 Same Cards 111, 222, 333, ... 29 for(i = 1; i < pai.size() - 1; i++) 30 { 31 if((pai[i-1].index == pai[i].index) && (pai[i].index == pai[i+1].index)) 32 { 33 DeleteNum(pai, pai[i-1].index); 34 DeleteNum(pai, pai[i-1].index); 35 DeleteNum(pai, pai[i-1].index); 36 if(isHuPai(pai)) 37 { 38 return TRUE; 39 } 40 } 41 } 42 43 // shunzi 123,345,567,... 44 for(i = 0; i < pai.size; i++) 45 { 46 if(pai.size >= 3) 47 { 48 if(lianpai(pai, pai[i].index++) && lianpai(pai, pai[i].index+2)) 49 { 50 DeleteNum(pai, pai[i].index); 51 DeleteNum(pai, pai[i].index+1); 52 DeleteNum(pai, pai[i].index+2); 53 54 if(isHuPai(pai)) 55 return TRUE; 56 } 57 } 58 } 59 60 if(Peng(tempvec)) 61 return false; 62 63 duizi = FALSE; 64 pai.clear(); 65 66 for(i = 0; i < tempvec.size(); i++) 67 pai.push_back(tempvec[i]); 68 69 if(isHuPai(pai)) 70 { 71 return TRUE; 72 } 73 } 74 return FALSE; 75 }