简洁明快!调用isPrime函数,然后获得min,再简单计算即可

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = Integer.MAX_VALUE;
        for (int i = 1; i <= n / 2; i++) {
            if (isPrime(i) && isPrime(n - i)) {
                min = Math.min(min, Math.abs(i - (n - i)));
            }
        }
        // 只要得到min,即可求出res =(n-min)/2
        int result = (n - min) / 2;
        System.out.println(result);
        System.out.println(n - result);
    }

    public static boolean isPrime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) return false;
        }
        return true;
    }

}