class Test
{
int result;
int fact(int n){
int result;
if(n==1)
{
return 1;
}
else
{
System.out.println("调用"+(n-1));
result=fact(n-1)*n;
//System.out.println("fac(n-1)="+fact(n-1));//我想打印fact(n-1)是什么?
System.out.println(" 返回"+n+" 当n="+n+"时 fact("+n+")="+"fact("+(n-1)+")*"+n+" 中间结果result=fact("+n+")="+result);
return result;
}
}
}
class demo
{
public static void main(String[] args)
{
Test t=new Test();
System.out.println("main::"+t.fact(5));
}
}
|
|