@@ -5,7 +5,6 @@ int get_shun_huxi_xiao(char* cards);
5
5
int get_shun_huxi_da (char * cards );
6
6
int get_shun_huxi_da_without_2_7_10 (char * cards , int num );
7
7
8
-
9
8
int get_huxi (char * cards )
10
9
{
11
10
int huxi = get_kan_huxi (cards );
@@ -27,12 +26,13 @@ int get_huxi(char* cards)
27
26
28
27
// 带将
29
28
int max_huxi = -1 ;
29
+ char tmp_cards [20 ];
30
30
for (int i = 0 ; i < 20 ; i ++ ) {
31
31
if (cards [i ] != 2 ) continue ;
32
- cards [i ] = 0 ;
33
- int other_huxi = get_shun_huxi_xiao (cards );
32
+ memcpy (tmp_cards , cards , 20 );
33
+ tmp_cards [i ] -= 2 ;
34
+ int other_huxi = get_shun_huxi_xiao (tmp_cards );
34
35
if (other_huxi > max_huxi ) max_huxi = other_huxi ;
35
- cards [i ] = 2 ;
36
36
}
37
37
38
38
if (max_huxi < 0 ) return -1 ;
@@ -79,7 +79,7 @@ int get_shun_huxi_xiao(char* cards) {
79
79
if (find ) {
80
80
find = 0 ;
81
81
int finded = 0 ;
82
- if (cur_item == 6 ) {
82
+ if (cur_item == 7 ) {
83
83
* (int * )0 = 0 ;
84
84
}
85
85
// 找到第一张牌
@@ -112,7 +112,7 @@ int get_shun_huxi_xiao(char* cards) {
112
112
// 顺子
113
113
if (items [cur_item ].i == 0 ) {
114
114
items [cur_item ].i = 1 ;
115
- if (cur_card < 8 && cards [cur_card + 1 ] > 0 && cards [cur_card + 1 ] > 0 ) {
115
+ if (cur_card < 8 && cards [cur_card + 1 ] > 0 && cards [cur_card + 2 ] > 0 ) {
116
116
items [cur_item ].j = 1 ;
117
117
items [cur_item ].card = cur_card ;
118
118
-- cards [cur_card ];
@@ -129,7 +129,7 @@ int get_shun_huxi_xiao(char* cards) {
129
129
// 小小大绞
130
130
if (items [cur_item ].i == 1 ) {
131
131
items [cur_item ].i = 2 ;
132
- if (cards [cur_card + 1 ] > = 2 && cards [cur_card + 10 ] >= 1 ) {
132
+ if (cards [cur_card ] = = 2 && cards [cur_card + 10 ] >= 1 ) {
133
133
items [cur_item ].j = 2 ;
134
134
cards [cur_card ] -= 2 ;
135
135
-- cards [cur_card + 10 ];
@@ -141,7 +141,7 @@ int get_shun_huxi_xiao(char* cards) {
141
141
// 大大小绞
142
142
if (items [cur_item ].i == 2 ) {
143
143
items [cur_item ].i = 3 ;
144
- if (cards [cur_card + 10 ] > = 2 ) {
144
+ if (cards [cur_card + 10 ] = = 2 ) {
145
145
items [cur_item ].j = 3 ;
146
146
cards [cur_card + 10 ] -= 2 ;
147
147
-- cards [cur_card ];
@@ -166,11 +166,13 @@ int get_shun_huxi_xiao(char* cards) {
166
166
}
167
167
168
168
huisu : // 回溯
169
- if (cur_item == 0 ) break ;
169
+ if (cur_item < 0 ) goto finish ;
170
170
171
- if (items [cur_item ].i == 0 || items [cur_item ].i == 4 ) {
171
+ if (items [cur_item ].i == 0 || ( items [cur_item ].i == 4 && items [ cur_item ]. j != 4 ) ) {
172
172
memset (& items [cur_item ], 0 , sizeof (struct Item ));
173
+ if (cur_item == 0 ) goto finish ;
173
174
-- cur_item ;
175
+ goto huisu ;
174
176
}
175
177
176
178
cur_card = items [cur_item ].card ;
@@ -193,9 +195,14 @@ int get_shun_huxi_xiao(char* cards) {
193
195
++ cards [1 ];
194
196
++ cards [6 ];
195
197
++ cards [9 ];
198
+ memset (& items [cur_item ], 0 , sizeof (struct Item ));
199
+ if (cur_item == 0 ) goto finish ;
200
+ -- cur_item ;
201
+ goto huisu ;
196
202
}
197
203
}
198
204
}
205
+ finish :
199
206
200
207
return max_huxi ;
201
208
}
@@ -223,16 +230,22 @@ int get_shun_huxi_da(char* cards) {
223
230
int max_huxi = -1 ;
224
231
225
232
for (int i = 0 ; i < 5 ; ++ i ) {
226
- if (cards [11 ] < i || cards [16 ] < i || cards [19 ] < i ) {
233
+ memcpy (tmp_cards , & cards [10 ], 10 );
234
+ tmp_cards [0 ] = 0 ;
235
+ tmp_cards [1 ] -= n_123 ;
236
+ tmp_cards [2 ] -= n_123 ;
237
+ if (tmp_cards [1 ] < i || tmp_cards [6 ] < i || tmp_cards [9 ] < i ) {
227
238
break ;
228
239
}
240
+
229
241
int huxi = get_shun_huxi_da_without_2_7_10 (tmp_cards , i );
230
242
if (huxi < 0 ) continue ;
231
243
if (huxi + n_123 * 6 > max_huxi ) max_huxi = huxi + n_123 * 6 ;
232
244
}
233
245
return max_huxi ;
234
246
}
235
247
248
+ //
236
249
int get_shun_huxi_da_without_2_7_10 (char * cards , int num )
237
250
{
238
251
char tmp_cards [10 ];
0 commit comments