問題詳情

18. 假設我們在 C 語言程式中定義如下函式。則以下選項何者正確?
int f(int n){if (n==1) return(1); else return 2*n+f(n-1);}
(A) f(2)=6
(B) f(4)=21
(C) f(6)=42
(D) 這是一個自己呼叫自己的錯誤程式
search(x, key)
if x = NIL or key = x.key then
return x
if key < x.key then
return search(x.left, key)
else
return search(x.right, key)
end if
圖三:第 15 題虛擬碼程式
a_list_of_tuples = [c for c in zip(['a', 'b', 'c', 'd', 'e'], range(5))]
a_dict = dict(a_list_of_tuples)
def cipherer(word, encoding=a_dict):
value = 0
for c in word:
value += encoding[c]
return value
圖四:第 17 題 Python 程式


稿


第 5 頁,共 8 頁

參考答案

答案:E

統計:A:0,B:0,C:1,D:3,E:0

難度:計算中