import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { String[] key=new String[] {"reset","reset board","board add","board delete","reboot backplane","backplane abort"}; String[] value=new String[] {"reset what","board fault","where to add","no board at all","impossible","install first"}; Scanner in = new Scanner(System.in); while(in.hasNextLine()) { String cmd = in.nextLine(); String[] arr = cmd.split(" "); if(arr.length < 1|| arr.length > 2) { System.out.println("unknown command"); continue; } if(arr.length == 1) { if(key[0].startsWith(arr[0])) { System.out.println(value[0]); }else { System.out.println("unknown command"); } continue; } int count = 0, idx = 0; for(int i = 1;i<key.length; i++) { String[] cmds = key[i].split(" "); if(cmds[0].startsWith(arr[0]) && cmds[1].startsWith(arr[1])) { count++; idx = i; } } if(count == 1) { System.out.println(value[idx]); }else { System.out.println("unknown command"); } } } }