package JavaText;
public class Text {
public static void main(String[] args) {
System.out.println(sum(100,0,0));
}
public static int sum(int a,int z,int sum){
if(z<=a){
sum+=z;
System.out.println(sum);
sum(a,++z,sum);
}
System.out.println(a); //100
System.out.println(z);//1,为什么输出为1而不是101?
System.out.println(sum);//0,为什么输出为0而不是5050?
return sum;
}
}
package JavaText;
public class Text {
public static void main(String[] args) {
System.out.println(sum(100,0,0));
}
public static int sum(int a,int z,int sum){
if(z<=a){
sum+=z;
System.out.println(sum);
sum=sum(a,++z,sum);
}
System.out.println(a); //100
System.out.println(z);//1,为什么输出为1而不是101?
System.out.println(sum);//0,为什么输出为0而不是5050?
return sum;
}
}