作者zptdaniel ()
看板TransCSI
标题Re: [问题] array问题
时间Mon May 11 21:48:26 2009
※ 引述《sky810675 (KKMAN)》之铭言:
: considering an array of record student[40], each record has three fields,
: namely, student, name, and score. if the data types of studentid, name,
: and score are integer (4 bytes), string (8 bytes), and short integer (2 bytes)
: respectively, please answer the following questions.
: 1.how many bytes in total are needed to store students?
: a. 560
: b. 40
: c. 14
: d. 160
Total = 40 * (4+8+2) = 40 * 14 = 560
: 2.if studentid[1] is stored in memory starting at loocation 1000 and the unit
: of memory location is byte, what is the staring address of students[10]?
: a. 1140
: b. 1010
: c. 1009
: d. 1126
∵4+8+2 = 14
∴14Bytes per element.
Loc(sudents[10])= 1000 + (10-1)*14 = 1000 + 126 = 1126
: 答案1.A
: 2.D
: 可以麻烦知道的人讲解一下为什麽吗??谢谢罗
--
当财团老板在剥削欺压劳工阶层时,我保持沉默,因为我不是广大劳动阶层。
当两党恶斗阶级世袭社会不公不义,我保持沉默,因为我非蓝非绿中间选民。
当学测考40几级分的权贵当医生时,没有人作声,因为全都死在手术台上了。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.194.100.216