int f() { static int i=0; int s=1; s+=i; i++; return s; }main() { int i,a=0; for(i=0;i
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/25 03:49:52
int f() { static int i=0; int s=1; s+=i; i++; return s; }main() { int i,a=0; for(i=0;i
int f() { static int i=0; int s=1; s+=i; i++; return s; }
main() { int i,a=0; for(i=0;i
int f() { static int i=0; int s=1; s+=i; i++; return s; }main() { int i,a=0; for(i=0;i
#include
int f() {
\x09static int i = 0;
\x09int s = 1;
\x09s += i;
\x09i++;
\x09return s;
}
int main() {
\x09int i,a = 0;
\x09for(i = 0; i < 5;i++) a += f();
\x09printf("%d\n",a);
\x09return 0;
}
/* 主函数main()共5次调用函数f()
1、调用前,i = 0,s = 1,s += i后,s = 1,i++后,i = 1.返回后,a = 0 + s = 0 + 1 = 1
2、调用前,i = 1,s = 1,s += i后,s = 2,i++后,i = 2.返回后,a = 1 + s = 1 + 2 = 3
3、调用前,i = 2,s = 1,s += i后,s = 3,i++后,i = 3.返回后,a = 3 + s = 3 + 3 = 6
4、调用前,i = 3,s = 1,s += i后,s = 4,i++后,i = 4.返回后,a = 6 + s = 7 + 4 = 10
5、调用前,i = 4,s = 1,s += i后,s = 5,i++后,i = 5.返回后,a = 10 + s = 10 + 5 = 15
*/