#include #include using namespace std; class card { public: char color; char value; int sortval; card(char nc, char nv): color(nc), value(nv) { switch(value){ case 'T': sortval = 10; break; case 'J': sortval = 11; break; case 'Q': sortval = 12; break; case 'K': sortval = 13; break; case 'A': sortval = 14; break; default: sortval = value - '0'; } switch(color){ case 'H': sortval += 14; case 'S': sortval += 14; case 'D': sortval += 14; } } }; class player { card* cards[14]; public: player() {int c; for(c=0;c<14;c++) cards[c] = NULL;} int insert(char nc, char nv) { int c, r; card* ncard; ncard = new card(nc,nv); for(c=13;c>=0;c--) { if(cards[c]) { if(cards[c]->sortval > ncard->sortval) {cards[c+1] = cards[c]; cards[c] = ncard; r = c;} } else { cards[c] = ncard; if(c<13) cards[c+1] = NULL; r = c; } } return r; } int printcards() { int c; cout << "+---+---+---+---+---+---+---+---+---+---+---+---+---+" << endl; for(c=0;c<14;c++) if(cards[c]) cout << "|" << cards[c]->value << " " << cards[c]->value; cout << "|" << endl; for(c=0;c<14;c++) if(cards[c]) cout << "| " << cards[c]->color << " "; cout << "|" << endl; for(c=0;c<14;c++) if(cards[c]) cout << "|" << cards[c]->value << " " << cards[c]->value; cout << "|" << endl; cout << "+---+---+---+---+---+---+---+---+---+---+---+---+---+" << endl; } }; int main() { string inp; int p = 0, c; char* players[4] = {"South player:","West player:","North player:","East player:"}; player* game[4]; while(getline(cin,inp) && (inp != "#")) { for(c=0;c<4;c++) game[c] = new player(); p = 0; switch(inp[0]){ case 'E': p += 1; case 'N': p += 1; case 'W': p += 1; case 'S': p += 1; } // while(getline(cin,inp) && (inp != "#")) for(int line = 0; line < 2; line++) { getline(cin, inp); for(c=0; cinsert(inp[c],inp[c+1]); p++;} } for(c=0;c<4;c++) {cout << players[c] << endl; game[c]->printcards(); delete game[c];} } return 0; }