第二题三个距离最短数java版本: public static void main(String[] args) { int index = 0; int[] nums = new int[]{33,44,61,2,36,42,56,81,11,17}; Arrays.sort(nums); System.out.println(); int k = 3; int sum ; int min = nums[nums.length - 1] + nums[nums.length - 2]+nums[nums.length - 3]; System.out.println(min); for(int i = 0;i < nums.length-3;i++){ sum = 0; for(int j = i+1;j< i+k;j++){ sum = sum+(nums[j] - nums[j - 1]); } if (sum < min){ min = sum; index = i; } } for (int i = index;i < index + 3;i++) System.out.println(nums[i] + " "); }