无脑
检查是否存在满足条件的数字组合
import java.util.Scanner;
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int count = Integer.parseInt(in.nextLine());
String[] split = in.nextLine().split(" ");
int[] arr = new int[count];
for (int i = 0; i < count; i++) {
arr[i] = Integer.parseInt(split[i]);
}
Arrays.sort(arr);
reverse(arr);
for (int i = 0; i < arr.length; i++) {
int A = arr[i];
for (int j = i + 1; j < arr.length; j++) {
int B = arr[j];
for (int k = j + 1; k < arr.length; k++) {
int C = arr[k];
if (A == B + 2 * C){
System.out.println(A + " " + B + " " + C);
return;
}
if (A == C + 2 * B){
System.out.println(A + " " + C + " " + B);
return;
}
}
}
}
System.out.println(0);
}
public static void reverse(int[] arr){
int l = 0;
int r = arr.length - 1;
while (l < r){
int temp = arr[l];
arr[l] = arr[r];
arr[r] = temp;
l++;
r--;
}
}
}
标签:arr,int,System,++,length,无脑
From: https://www.cnblogs.com/aclq/p/17770549.html