i=1:y_static=y_static(1)*i//////////y=fac(i);
=1;
y_for=y_static=1;
///////////return y
y_static=y_static(1)*i//////////cout<<fac(i);
fac(i) =y_static=1;
////////return y
out:1
i=2: y_static=y_static(1)*i//////////y=fac(i);
=2
y_for=y_static=2;///////////return y
ystatic=y_static(2)*i//////////cout<<fac(i);
=4;
fac(i)=y_static=4;/////////return y
out:4
i=3: y_static=y_static(4)*i//////////y=fac(i);
=12
y_for=y_static=12;//////////////return y;
y_static=y_static(12)*i;////////////////////cout<<fac(i);
=36;
fac(i)=y_static=36;///////////return y;
out:36
i=4:
y_static=y_static(36)*i;//////////y=fac(i);
=144;
y_for=y_static=144;///////////return y;
y_static=y_static(144)*i//////////cout<<fac(i);
=576;
fac(i)=y_static=576;/////////return y;
out:576
i=5: y_static=y_static(576)*i///////y=fac(i);
=2880
y_for=y_static=2880;//////////return y;
y_static=y_static(2880)*i///////////////////cout<<fac(i);
=14400
fac(i)=y_static=14400;//////////return y;
out:14400
其中y_for指 for 内的临时变量y;y_static指fac函数中的静态变量y;括号里的数字指变量当时的值;out指输出的数。