转载 public class d11 { static int[] a = new int[1000]; public static void main(String[] args) { // TODO Auto-generated method stub Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = Integer.parseInt(scanner.nextLine()); a[0] = n; cal(n, 1); } } public static void cal(int n, int p) { for (int i = n < a[p - 1] ? n : a[p - 1]; i > 0; i--) { a[p] = i; if (n == i) { System.out.printf("%d=%d", a[0], a[1]); for (int j = 2; j <= p; j++) { System.out.printf("+%d", a[j]); } System.out.println(); } else { cal(n - i, p + 1); } } } }