[Problem description]
Everyone should be familiar with poker games. A deck consists of 54 cards, including 3 ~ A, 2, 4, 1, and 1 respectively. The card surface is represented by the following characters and strings (in which, the lower-case Joker represents the King, and the upper-case Joker represents the King ):
3 4 5 6 7 8 9 10 j q k a 2 Joker
Enter two cards and connect them with "-". Each card of each hand is separated by a space. There is no space between the two cards, for example, 4 4 4 4-Joker.
Compare the two-hand card size and output a large card. If there is no comparison relationship, an error is returned.
Basic rules:
(1) Each hand may be a sub-, sub-, shunzi (five in a row), three, a bomb (four in a row), or a sub-King. There are no other situations, ensure that the two cards are valid from input, and the sub-accounts are arranged from small to large;
(2) Except for the comparison between bombs and kings and all cards, cards of other types can only be compared with those of the same type (for example, the comparison between the pair and the pair, if you do not consider card splitting, for example, splitting the sub-account into sub-accounts );
(3) The size rules are the same as the common rules that you know at ordinary times. The sub-, sub-, and sub-sides are compared with the card sizes; the sub-accounts are compared with the minimum card sizes; the bombs are larger than all the cards above, the bomb is the largest card;
(4) The two cards entered are not equal.
It took two hours to finish writing and there was no problem in testing on your computer. After submission, the error 10 and error 129 errors always occur. It has not been successful for a long time. I hope you can help us to discuss how to solve this error.
[Code]
# Include <stdio. h> # include <stdlib. h> # include <string. h>/* type indicates the type of the input card. 0 single King 1 sub (not including single king) 2 sub-3 sub-sub 4 three five bomb 6 sub-king */void getstrtype (char * poker, char * firstpoker, int * type) {int I, Len; int count; Len = strlen (poker); I = 0; while (poker [I]! = ''& I <= Len) {firstpoker [I] = poker [I]; I ++;} firstpoker [I] = '\ 0 '; I = COUNT = 0; while (I <Len) {If (poker [I] = '') Count ++; I ++;} If (0 = count) {If (strlen (firstpoker) <5) * type = 1; else * type = 0;} else if (1 = count) {If (strlen (firstpoker) <5) * type = 2; else * type = 6;} else if (2 = count) * type = 4; else if (3 = count) * type = 5; else * type = 3;} int pokercmp (char * Str) {int I, j, Len; int CMP; char Poker1 [128], poker2 [128]; char firstpoker1 [32], firstpoker2 [32]; int type1, type2; Len = strlen (STR ); while (STR [Len-1] = '') Len --; If (0 = Len) return 0; If (128 <Len) Return-1; I = J = 0; while (STR [I]! = '-') Poker1 [J ++] = STR [I ++]; poker1 [J] = '\ 0'; I ++; j = 0; while (I <= Len) poker2 [J ++] = STR [I ++]; If (0 = strlen (poker1) | 0 = strlen (poker2 )) return 0; getstrtype (poker1, firstpoker1, & type1); getstrtype (poker2, firstpoker2, & type2);/* compare the size */If (6 = type1) | (5 = type1 & 5> type2) printf ("% s", poker1); else if (6 = type2) | (5 = type2 & 5> type1) printf ("% s", poker2); else if (0 = type1 && 1 = type2) printf ("% s", poker1); else if (0 = type2 & 1 = type1) printf ("% s", poker2 ); else if (type1 = type2) {If (type1 = 0) {If ('J' = poker1 [0]) printf ("% s", poker1 ); elseprintf ("% s", poker2);} else if (type1 = 3) // shunzi, A, 2, 3, 4, 5, 2, 3, 4, 5, 6 cannot constitute a sup {CMP = strcmp (firstpoker1, firstpoker2); If (0> CMP) printf ("% s", poker2); elseprintf ("% s ", poker1);} else // 1, 2, 4, 5 {If ('2' = firstpoker1 [0] | ('A' = first Poker1 [0] & '2 '! = Firstpoker2 [0]) printf ("% s", poker1 ); else if ('2' = firstpoker2 [0] | ('A' = firstpoker2 [0] & '2 '! = Firstpoker1 [0]) printf ("% s", poker2); else {CMP = strcmp (firstpoker1, firstpoker2); If (0> CMP) printf ("% s", poker2); elseprintf ("% s", poker1) ;}} elseprintf ("error"); return 1 ;}int main (void) {char STR [128]; gets (STR); pokercmp (STR); Return 0 ;}