subject
Ruishen HRZ is bored at home because of the epidemic. At the same time, he is very fierce. All his classes are water and water can get A +, so he is bored. He finds three other people: gugudong, TENGSHEN and zjm to play cards (the world's bitter Ruishen has been for A long time).
Obviously, the game is made up of four people in a circle. We call the four directions North, Southeast and West. The corresponding English is North, East, South, West. The game consists of 52 playing cards. At first, we appointed a dealer (one in the southeast and northwest, marked with English initials) to start licensing. The order of licensing was clockwise. The first dealer did not issue himself, but issued his next person (the next person clockwise). That way, everyone gets 13 cards.
Now we define the order of cards. First of all, the decor is (plum blossom) < (square piece) < (spade) < (red peach). (when inputting, we use C,D,S,H to represent plum blossom, square piece, spade, and red peach respectively, that is, the initial of the word). For deck values, we specify 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < T < J < Q < K < a.
Now, as God, you have to sort everyone's cards from small to large and output them in a given format. (see output description and sample output for specific format).
Input
Input contains multiple sets of data
The first line of each set of data contains an uppercase character indicating who the dealer is. If the character is' × ', it means the end of input.
Next there are two lines, each with 52 characters, representing 26 cards, and the two lines add up to 52 cards. Each card consists of two characters. The first character represents the decor and the second character represents the value.
Output
Output multiple groups of data licensing results, each group of data after the need to output an additional blank line!!!!!
Each group of data should be composed of 24 lines. The output should be clockwise and always output south first As a result of player, each player first outputs one line, namely player name (southeast, northwest), then five lines, the first line and the fifth line output fixed format (see the example), the second line and the fourth line output values in order and format (see the example), and the third line output patterns in order and format (see the example).
Analysis
Licensing refers to the normal way four people play cards, one er one card, one er one Er, Feng Shui Er turns around in turn, er into ten thousand dollars tonight.
Refer to upper North lower South left West right east.
Suppose A is in the east of the table, and A is selected for licensing, then the licensing sequence is south, West, North and East (the last one in each cycle). The input string is the suit and value of each card. After reading in, use sort() to first color (C < d < s < h) and then number (2 < < 9 < T < J < Q < K < A). Letters can be mapped to numbers (for example, T=10).
Sample Input
N
CTCAH8CJD4C6D9SQC7S5HAD2HJH9CKD3H6D6D7H3HQH4C5DKHKS9
SJDTS3S7S4C4CQHTSAH2D8DJSTSKS2H5D5DQDAH7C9S8C8S6C2C3
#
Sample Output
The complete code is attached below (VJ test passed; lang: C + +)
#include<iostream> #include<cstdlib> #include<map> #include<algorithm> #include<cstring> using namespace std; struct Card { char cshape; char cfigure; int shape;//Number of decor mapping int figure;//Number of face mapping Card(){ shape=-1;figure=-1; } void setCard(char _cshape,int _shape,char _cfigure,int _figure) { cshape=_cshape; cfigure=_cfigure; shape=_shape; figure=_figure; } bool operator<(const Card& other) { if(shape!=other.shape) return shape<other.shape; if(figure!=other.figure) return figure<other.figure; return false; } /* data */ }; void print(Card* p) { for(int i=0;i<13;i++){ printf("+---"); } printf("+\n");//1 for(int i=0;i<13;i++){ printf("|%c %c",p[i].cfigure,p[i].cfigure); } printf("|\n");//2 for(int i=0;i<13;i++){ printf("| %c ",p[i].cshape); } printf("|\n");//3 for(int i=0;i<13;i++){ printf("|%c %c",p[i].cfigure,p[i].cfigure); } printf("|\n");//2 for(int i=0;i<13;i++){ printf("+---"); } printf("+\n");//1 } int main() { //freopen("777.txt","r",stdin); map<char,int> fmp; for(char i='2',k=2;i<='9';i++){ fmp[i]=k++; } fmp['T']=10; fmp['J']=11; fmp['Q']=12; fmp['K']=13; fmp['A']=14; fmp['N']=0; fmp['E']=1; fmp['S']=2; fmp['W']=3; map<char,int> smp; smp['C']=0; smp['D']=1; smp['S']=2; smp['H']=3; Card* hands[4];//Four players, p0~1 for their hands Card p0[13]; hands[0]=p0; //N Card p1[13]; hands[1]=p1; //E Card p2[13]; hands[2]=p2; //S Card p3[13]; hands[3]=p3; //W char guard; while(true) { scanf("%c",&guard); if(guard=='#') break; int whose=fmp[guard]; char cards[106]; scanf("%s",cards); scanf("%s",cards+52); getchar(); for(int i=0;i<104;i++) { char cs=cards[i]; int is=smp[cs]; i++; char cf=cards[i]; int iv=fmp[cf]; (hands[(++whose)%4])[i/8].setCard(cs,is,cf,iv); } //for(int i=0;i<4;i++) sort(hands[i],hands[i]+13); sort(p2,p2+13); printf("South player:\n"); print(p2); sort(p3,p3+13); printf("West player:\n"); print(p3); sort(p0,p0+13); printf("North player:\n"); print(p0); sort(p1,p1+13); printf("East player:\n"); print(p1); cout<<endl; } //system("pause"); return 0; }