Examly題庫立即開始練習
2 類科共用卷
普考-電信工程普考-電子工程
計算機概要10927單選題

呼叫下列C函式時若傳入字串"To be or not to be, that's the question",則回傳值為何? int fn(char *s) { int num=0; while (*s) if (*s++ ==' ') num++; return num; }

A5
B6
C7
D8正確答案
答案與詳解
D
正確答案
此函式計算字串中空格數量,逐字檢查遇到空白字元就累加。

為什麼答案是 D

字串 'To be or not to be, that's the question' 有 8 個空格:To|be|or|not|to|be,|that's|the|question,單字間共 8 個空白。

考點:數量錯誤考點:易錯陷阱考點:字元計數
載入中…

計算機概要 相關題目

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

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

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