#include #include #include using namespace std; void update(char nc,int n[],int *c){ if(nc=='T') n[(*c)++]=10; else if(nc=='A') n[(*c)++]=1; else if(nc=='J') n[(*c)++]=11; else if(nc=='Q') n[(*c)++]=12; else if(nc=='K') n[(*c)++]=13; else n[(*c)++]=nc-'0'; } void printcard(char nc,int n[],int c){ for(int i=0;i>N; for(int i=0;i>mn; if(mn[0]=='D') update(mn[1],dn,&dc); else if(mn[0]=='C') update(mn[1],cn,&cc); else if(mn[0]=='H') update(mn[1],hn,&hc); else if(mn[0]=='S') update(mn[1],sn,&sc); } int sumc=dc+cc+hc+sc; sort(dn,dn+dc); sort(cn,cn+cc); sort(hn,hn+hc); sort(sn,sn+sc); if(dc!=0){ sumc-=dc; printcard('D',dn,dc); if(sumc!=0) cout<<" "; } if(cc!=0){ sumc-=cc; printcard('C',cn,cc); if(sumc!=0) cout<<" "; } if(hc!=0){ sumc-=hc; printcard('H',hn,hc); if(sumc!=0) cout<<" "; } if(sc!=0){ sumc-=sc; printcard('S',sn,sc); if(sumc!=0) cout<<" "; } cout<