package day07;
import java.util.Scanner;
public class day08 {
static int []a = new int[100];
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
number(n,0,n,0);
}
public static void number(int n,int sum,int max,int j){
for(int i = n;i>0;i--){
sum = i;
if(sum>max){
break;
}else if(sum == n){
a[j] = i;
int temp=0;
for(int k=0;k<=j;k++){
temp += a[k];
}
if(temp!=max){
continue;
}
for(int k=0;k<=j;k++){
System.out.print(a[k]);
if(k!=j){
System.out.print("+");
}
}
System.out.println();
}
else{
a[j] = i;
number(n-1,sum,max,j+1);
}
}
}
}
代码写的不是很简介,请批评指正!
|