//pseudocode
//n and k are nonnegative integers`
int f(int n, int k)`
`if(k*n ==0)`
`return 1`
`else`
`return f(n-1,k-1)+f(n-1,k)`
`end if`
end f
到目前为止,我有这个。但是如何找到此函数调用的值?
f(3,1) + f(3,2)
f(2,0) +f(2,1) f(2,1)+f(2,2)
1 f(1,0)+f(1,1) f(1,1)+f(1,2)
f(0,0)+f(0,1) f(0,1)+f(0,2)
答案 0 :(得分:0)
基本上答案就是继续你的开始:
f(4, 2) ; ==
f(3, 1) + f(3, 2) ; ==
f(2, 0) + f(2, 1) + f(2, 1) + f(2, 2) ; ==
1 + f(1, 0) + f(1, 1) + f(1, 0) + f(1, 1) + f(1, 1) + f(1, 2) ; ==
1 + 1 + f(0, 0) + f(0, 1) + 1 + f(0, 0) + f(0, 1)+ f(0, 0) +
f(0, 1) + f(0, 1) + f(0, 2) ; ==
1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 ; ==
11
答案 1 :(得分:0)