Examly題庫立即開始練習
地方政府公務人員四等-資訊處理類科計算機概要10419單選題

下列程式執行後,執行結果為何? #include "stdafx.h" #include "stdio.h" int fun5(int x){ if (x <=1) return 1; else return x * fun5(x-1); } int _tmain(int argc, _TCHAR* argv[]) { int c=fun5(6); printf_s("%d\n", c); return 0 ; }

A0
B1
C120
D720正確答案
答案與詳解
D
正確答案
遞迴計算階乘 6! = 720,典型遞迴函式考題。

為什麼答案是 D

fun5(6)=6×5×4×3×2×1=720。遞迴展開:6*fun5(5)=6*120=720。

考點:干擾選項考點:忽略遞迴展開考點:終止條件誤算考點:階乘遞迴
載入中…

計算機概要 相關題目

想練更多計算機概要考古題?

Examly 收錄 38 萬+ 道歷屆題目,每題都有像這樣的精選詳解。免費下載,立即開練。

Download on theApp Store即將推出Google Play
黑皮