Examly題庫立即開始練習
身心障礙人員考試身障四等-資訊處理類科計算機概要11020單選題

下列 C 程式執行後的輸出為何? #include <stdio.h> int main(void) { int a[4][3] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12} }; printf("%d", *((int*)a+8)); return 0; }

A3
B8
C9正確答案
D11
答案與詳解
C
正確答案
二維陣列在記憶體中連續存放,(int*)a+8 指向第 9 個元素 = 9。

為什麼答案是 C

(int*)a 將二維陣列轉為 int 指標,+8 指向第 9 個 int (偏移 8),即 a[2][2]=9。*解參考得 9。

考點:偏移計算考點:指標位移陷阱考點:指標解參考
載入中…

計算機概要 相關題目

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

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

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