题解 | #扑克牌大小#
扑克牌大小
https://www.nowcoder.com/practice/d290db02bacc4c40965ac31d16b1c3eb
搞了半天每个人只有一种类型的牌
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String card = "3 4 5 6 7 8 9 10 J Q K A 2 joker JOKER"; // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextLine()) { // 注意 while 处理多个 case String[] hands = in.nextLine().split("-"), hands0 = hands[0].split(" "), hands1 = hands[1].split(" "); if (hands0.length == hands1.length) { System.out.println(card.indexOf(hands0[0]) > card.indexOf(hands1[0]) ? hands[0] : hands[1]); } else { if ("joker JOKER".equals(hands[0]) || "joker JOKER".equals(hands[1])) { System.out.println("joker JOKER"); } else if (hands0.length == 4) { System.out.println(hands[0]); } else if (hands1.length == 4) { System.out.println(hands[1]); } else { System.out.println("ERROR"); } } } } }