package LanQiao.C_Web.C_1975;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;
public class C1975 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String str = input.next();
ArrayList<Poker> list = new ArrayList();
int i = 0;
while(i < str.length()){
if (str.charAt(i) <= '9' && str.charAt(i) >= 2){
list.add(new Poker("" + str.charAt(i),str.charAt(i+1)));
i = i + 2;
}else if (str.charAt(i) == 'J') {
list.add(new Poker("J",str.charAt(i+1)));
i = i + 2;
}else if (str.charAt(i) == 'Q') {
list.add(new Poker("Q",str.charAt(i+1)));
i = i + 2;
}else if (str.charAt(i) == 'K') {
list.add(new Poker("K",str.charAt(i+1)));
i = i + 2;
}else if (str.charAt(i) == 'A') {
list.add(new Poker("A",str.charAt(i+1)));
i = i + 2;
}else{
list.add(new Poker("10", str.charAt(i+2)));
i = i + 3;
}
}
list.sort(new Comparator<Poker>(){
public int compare(Poker o1,Poker o2){
if(o2.num > o1.num) return -1;
else if (o2.num < o1.num) return 1;
else {
if(o2.color > o1.color) return -1;
else if (o2.color < o1.color) return 1;
else return 0;
}
}
});
for(Poker result : list){
System.out.print(result.num_o + result.color_o + " ");
}
}
}
class Poker{
String num_o;
char color_o;
int num;
char color;
public Poker(String num,char color){
if (num == "J") this.num = 11;
else if(num == "Q") this.num = 12;
else if (num == "K") this.num = 13;
else if (num == "A") this.num = 14;
else this.num = Integer.parseInt(num);
if(color == 'd') this.color = 1;
else if (color == 'c') this.color = 2;
else if (color == 'h') this.color = 3;
else if (color == 's') this.color = 4;
this.num_o = num;
this.color_o = color;
}
}
|