前 3 个问题我分别得到 6,4,3,但我不知道如何弄清楚最后一个问题。但是,解决方案手册将 7、5、4、18 作为答案。
int sum(int x[], int N) {
int k = 0;
int s = 0;
while (k < N) {
s = s + x[k];
k = k + 1;
}
return s; // the activation record for sum will be ____________ locations
}
int fred(int a, int b) {
return a + b; // (2) the activation record for fred will be ____________ locations
}
void barney(int x) {
x = fred(x, x);//(2) the activation record for barney will be ____________ locations
}
void main(void) {
int a[4];
int x = sum(a, 4);
barney(x);
} // (3) the stack must have at least _____________ locations to run this program