[問題] 100台聯大計概考古

看板TransCSI作者 (PP瑄)時間12年前 (2012/06/29 15:59), 編輯推噓2(205)
留言7則, 2人參與, 最新討論串1/1
4.Consider the C program on the right side.What will be printed on the standard output after program finishes? struct point{int x;int y;}; int main(){ struct point p,q; struct point *r; r=&q; q.x=p.y=1; q.y=p.x=2; r->x=2; p.y=1; printf("%d,%d",q.x,q.y); return 0; } A.2,2 B.2,1 C.1,2 D.1,1 E.none of the above 2.A 2D array X[1...10][1...100]is declared in a program.The address of X[1][1]is 1200,and the size of each element of the array is 4.What address of X[3][2]is if the memory system uses row majar storage? A.1232 B.1264 C.1328 D.2408 E.none of the above 請問這兩題的答案怎麼算 第二題 我算出來都不是ABCD裡.. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.27.127.148

07/01 01:45, , 1F
第二題我算是 2004
07/01 01:45, 1F

07/01 01:46, , 2F
第一題是 A 嗎?
07/01 01:46, 2F

07/01 01:49, , 3F
用程式跑一次, 第一題是 A 無誤。
07/01 01:49, 3F

07/01 01:50, , 4F
第一題重點在 call-by-reference. r & q 共用記憶體空間
07/01 01:50, 4F

07/01 01:51, , 5F
原本 q.x = 1, 後來 r.x = 2 --> q.x = 2
07/01 01:51, 5F

07/01 02:31, , 6F
第二題我也算2004,沒在答案上比較不放心..第一題大概了
07/01 02:31, 6F

07/01 02:32, , 7F
解了,不過細微的得自己再去弄懂,真的謝謝你!
07/01 02:32, 7F
文章代碼(AID): #1FxM1YCe (TransCSI)