#include #include #include #include char S1[]="CDSH"; char S2[]="23456789TJQKA"; int Q[4][13]; int qn[4]; int fmap(char *s) { char s1[2], s2[2]; s1[0]=s[0]; s1[1]=0; s2[0]=s[1]; s2[1]=0; return (strstr(S1,s1)-S1)*100 + (strstr(S2,s2)-S2); } void bmap(int z, char *s) { s[2]=0; s[0]=S1[z/100]; s[1]=S2[z%100]; } int cmp(const void *a, const void *b) { int *A=a; int *B=b; if (*A<*B) return -1; if (*A>*B) return 1; return 0; } void Pis() { int i,k; char s[3]; char N[4][10]={"South","West","North","East"}; for(k=0;k<4;k++) { printf("%s player:\n+",N[k]); for(i=0; i<13;i++) printf("---+"); printf("\n|"); for(i=0; i<13;i++) { bmap(Q[k][i],s); printf("%c %c|",s[1],s[1]); } printf("\n|"); for(i=0; i<13;i++) { bmap(Q[k][i],s); printf(" %c |",s[0]); } printf("\n|"); for(i=0; i<13;i++) { bmap(Q[k][i],s); printf("%c %c|",s[1],s[1]); } printf("\n+"); for(i=0; i<13;i++) printf("---+"); printf("\n"); } } int main() { char q; int i,j,f; char s[3]; f=1; while(1) { scanf("%c ",&q); if (q=='#') break; if (!f) printf("\n"); f=0; for (i=0; i<4;i++) qn[i]=0; if (q=='S') i=1; else if (q=='W') i=2; else if (q=='N') i=3; else if (q=='E') i=0; for (j=0; j<52;j++) { scanf("%2s ",s); Q[i][qn[i]++]=fmap(s); i++; i=i%4; } for (i=0; i<4;i++) qsort(Q[i],qn[i],sizeof(int),cmp); Pis(); } return 0; }