题解 | #扑克牌大小#
扑克牌大小
https://www.nowcoder.com/practice/d290db02bacc4c40965ac31d16b1c3eb
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();
String[] pokes = s.split("-");
System.out.println(compare(pokes[0], pokes[1]));
}
static String compare(String poke1, String poke2){
String allPoke = "3 4 5 6 7 8 9 10 J Q K A 2 joker JOKER";
String[] ss = allPoke.split(" ");
Map<String, Integer> map = new HashMap();
for (int i = 0; i < ss.length; i++) {
map.put(ss[i], i);
}
String[] s1s = poke1.split(" ");
String[] s2s = poke2.split(" ");
if (s1s.length != s2s.length){
if (poke1.equals("joker JOKER")) return poke1;
if (poke2.equals("joker JOKER")) return poke2;
if (s1s.length==4) return poke1;
if (s2s.length==4) return poke2;
return "ERROR";
}else {
if (map.get(s1s[0])>map.get(s2s[0])) return poke1;
else return poke2;
}
}
}

