作者fb74123698 (PP瑄)
看板TransCSI
标题[问题] 100台联大计概考古
时间Fri Jun 29 15:59:27 2012
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
1F:推 forris:第二题我算是 2004 07/01 01:45
2F:→ forris:第一题是 A 吗? 07/01 01:46
3F:推 forris:用程式跑一次, 第一题是 A 无误。 07/01 01:49
4F:→ forris:第一题重点在 call-by-reference. r & q 共用记忆体空间 07/01 01:50
5F:→ forris:原本 q.x = 1, 後来 r.x = 2 --> q.x = 2 07/01 01:51
6F:→ fb74123698:第二题我也算2004,没在答案上比较不放心..第一题大概了 07/01 02:31
7F:→ fb74123698:解了,不过细微的得自己再去弄懂,真的谢谢你! 07/01 02:32