執行下列 C 語言所寫的程式之後,應該看到甚麼? #include <stdio.h> #include <stdlib.h> void main() { printf("%d\n",abc(5)); } int abc(int t){ if (t<0) return 0; if (t<=1) return 1; else return abc(t-1)+abc(t-2); }
A5
B8正確答案
C13
D以上皆非
答案與詳解
正確追蹤遞迴過程,abc(5) = abc(4) + abc(3) = 5 + 3 = 8。
Examly 收錄 38 萬+ 道歷屆題目,每題都有像這樣的精選詳解。免費下載,立即開練。
