快手校招第一题不知道错哪里了啊 调试了50分钟 绝望了
有没有一样的小伙伴啊
public class Main {
public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNext()) { int cishu = Integer.valueOf(in.nextLine()); int[] result = new int[cishu]; for (int i = 0; i < cishu; i++) { String[] line = in.nextLine().split(" "); String[] string1 = line[0].split("\\."); String[] string2 = line[1].split("\\."); int length = Math.min(string1.length, string2.length); int flag = 0; int indeed = 0; for (int j = 0; j < length; j++) { int a = Integer.valueOf(string1[j]); int b = Integer.valueOf(string2[j]); if (b > a) { flag = 0; indeed = 1; break; } else if (b == a) { continue; } else { flag = 1; break; } } if (string1.length > string2.length && flag == 0) { flag = 1; } if (string2.length > string1.length && flag == 0) { int max = 0; for (int j = string1.length; j < string2.length; j++) { max = Math.max(max, Integer.valueOf(string2[j])); } if (max == 0) { flag = 1; } } if (indeed == 1) { result[i] = 1; } else { if (flag == 0) { result[i] = 1; } else { result[i] = 0; } } } for (int i = 0; i < cishu; i++) { if (result[i] == 1) { System.out.println("true"); } else { System.out.println("false"); } } } }
}