穷举。从num/2开始往下判断,如果两个数都是质数,那么直接打印结果即可。

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int num = in.nextInt();
            for(int i=num/2;i>=0;--i){
                if(i==2||i%2!=0)
                if(get(i)&&get(num-i)){
                    System.out.print(i+"\n"+(num-i));
                    return;
                }
            }
            
        }
    }
    public static boolean get(int num){
        for(int i=2;i<=num/i;++i){
            if(num%i==0)return false;
        }
        return true;
    }
}