import java.util.Scanner; import java.util.Map; import java.util.HashMap; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { private static Map<String[], String> map = new HashMap<>(); static { map.put(new String[]{"reset"}, "reset what"); map.put(new String[]{"reset","board"}, "board fault"); map.put(new String[]{"board","add"}, "where to add"); map.put(new String[]{"board","delete"}, "no board at all"); map.put(new String[]{"reboot","backplane"}, "impossible"); map.put(new String[]{"backplane","abort"}, "install first"); } public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextLine()) { // 注意 while 处理多个 case String str = in.nextLine(); process(str); } } private static void process(String str){ String[] strs = str.split(" "); String res = null; for(Map.Entry<String[], String> entry : map.entrySet()) { String[] k = entry.getKey(); if(strs.length != k.length) { continue; } boolean f = true; for(int i = 0; i< strs.length; i++) { String sim = strs[i]; String commod = k[i]; for(int j = 0; j< sim.length(); j++) { if(sim.charAt(j) != commod.charAt(j)) { f = false; break; } } if(!f) break; } if(f && res == null) { res = entry.getValue(); } else if(f && res != null) { System.out.println("unknown command"); return; } } if(res == null) { System.out.println("unknown command"); }else { System.out.println(res); } } }