67,515
社区成员
发帖
与我相关
我的任务
分享
private static long count=1;
private static long add(long num){
long t=num;
if(count>=1 && count<=100){
t=t+count;
count++;
add(t);
}else{
return t;
}
return t;
}
//调用
System.out.println(add(1));//打印的值是2...没明白
private static long count=1;
private static long add(long num){
long t=num;
if(count>=1 && count<=100){
t=t+count;
count++;
t=add(t);//没测试,但是你这里原来肯定不对,而且下面的那个else{return ...}可以去掉
}
return t;
}
//调用
System.out.println(add(1));//打印的值是2...没明白