#include #include #include #include #include #include // Yukicoder №267 トランプソート // https://yukicoder.me/problems/no/267 // *********************** // for debug #define DEBUG7 #define NOP do{}while(0) #ifdef DEBUG #define TRACE(...) do{printf(__VA_ARGS__);fflush(stdout);}while(0) #define TRACECR do{printf("\n");fflush(stdout);}while(0) #else #define TRACE(...) NOP #define TRACECR NOP #endif #define PRINCR printf("\n") #define NOCR(strig) do{char *p;p=strchr(strig,'\n');if(p)*p='\0';}while(0) // The out-of-date function #define asctime(...) asctime_s(...) #define ctime(...) ctime_s(...) #define strlen(a) mystr_len(a) //#define fopen(...) fopen_s(...) //#define freopen(...) freopen_s(...) //#define rewind(a) fseek(a,0L,SEEK_SET) //#define setbuf(a,b) setvbuf(a,b,_IOFBF,BUFSIZ) // for stdio #define INPUT(str) do{char *p;fgets(str,sizeof(str),stdin);p=strchr(str,'\n');if(p)*p='\0';}while(0) #define mygc(c) (c)=getchar() static char *getinput( char* str ); static char *getinput(char* str) {char c;char *cp;cp=&str[0];c=fgetc(stdin);while( c != EOF ){if((c==' ')||( c=='\n')) break;*cp++=c;c=fgetc(stdin);}*cp='\0';return &str[0];} static int max(int a,int b){if(a>b){return a;}return b;} static int min(int a,int b){if(a*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;} static int cmpint_desc(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;} static int cmpchar_asc(const void *a,const void *b){if(*(char *)a>*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;} static int cmpchar_desc(const void *a,const void *b){if(*(char *)a<*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;} static int mystr_len(char *str){int i=0;do{if(str[i]=='\0')break;i++;if(i>9999)break;}while(1);return i;} static int countchar(char str[],char c,int limit ) {int cnt = 0;for(int i=0;inum; d =(CARD_t*)bp; b = d->num; #if 0 // 1 is 降順 5 4 3 2 1 if( a > b ) return -1; else if( a < b ) return 1; else return 0; #else // 0 is 昇順 1 2 3 4 5 if( a < b ) return -1; else if( a > b ) return 1; else return 0; #endif } // *********************** int main() { char str[INPBUF]; int query; CARD_t cards[20]; int val; INPUT( str ); sscanf( str,"%d", &query ); REP(i,query) { getinput( str ); switch( str[0] ) { case 'D': val = 100; break; case 'C': val = 200; break; case 'H': val = 300; break; case 'S': val = 400; break; } switch( str[1] ) { case 'A': val += 1; break; case 'T': val += 10; break; case 'J': val += 11; break; case 'Q': val += 12; break; case 'K': val += 13; break; default: val += (str[1] - '0'); } cards[i].num = val; cards[i].str[0] = str[0]; cards[i].str[1] = str[1]; cards[i].str[2] = '\0'; } qsort( cards , query, sizeof( cards[0] ), cmpcards ); REP(i,query) { if(i) printf(" "); printf("%s", cards[i].str ); } return 0; }