import java.util.Arrays; public class _Test_44{ public static void main(String[] args) { int[] numbers = {1,3,6,4,5}; _Test_44 c = new _Test_44(); boolean f = c.isCountious(numbers); System.out.println(f); } public boolean isCountious(int[] numbers) { int numberZero = 0;//表示的是大小王也就是零的个数 int numberOfNum = 0;//这个表示间隔的数 if (numbers.length == 0) { return false; } Arrays.sort(numbers);//进行排序 for (int i = 0; i < numbers.length - 1; i++) { //统计大小王的个数 if (numbers[i] == 0) { numberZero++; continue; } //判断是不是出现对子 if (numbers[i] == numbers[i + 1]) { return false; } //计算两两之间间隔的数字 numberOfNum += numberOfNum + numbers[i + 1] - numbers[i] - 1; } return numberOfNum <= numberZero ? true :false; } }