1 / 13

4 章 课后习题

4 章 课后习题. 1. 试写出下列类型的内部表示: a. Integer b. ARRAY[1..5] OF RECORD i:integer; b:Boolean END. c. ARRAY [1..5] OF RECORD a: ARRAY [1..10]; r: RECORD

vea
Download Presentation

4 章 课后习题

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 4章 课后习题 1.试写出下列类型的内部表示: a. Integer b. ARRAY[1..5] OF RECORD i:integer; b:Boolean END

  2. c.ARRAY [1..5] OF RECORD a: ARRAY [1..10]; r: RECORD i, j: integer END END d. RECORD r:RECORD x, y: real END; a:ARRAY[1..10] OF integer END

  3. i r b a d integer: i nil b. LOW UP CTP CLEN a 1 5 2 d i 0 itp b 1 btp 解:a. TYPEL 类型表

  4. a 1 5 12 d a 0 atp r 10 rtp' d i 0 itp j 1 itp rtp’ c.

  5. r 0 rtp’ a 2 atp a 1 10 itp 1 atp x 0 rtp y 1 rtp d rtp’ d. d

  6. 2.设当前层数为l,可用区距为101,且有下列程序段:2.设当前层数为l,可用区距为101,且有下列程序段: CONST mm=333; nn=444; TYPE atype=ARRAY[1..10] OF real; rtype=RECORD i,j :integer END; VAR a, b: atype; x, y: real 试写出各标识符的语义字(SYMBL, TYPEL,AINFL,RINFL).

  7. 解: TYPE CLASS(种类) ADDER Itp c <333> mm: 类型c t r p d f r 常量 类型 变量 过函 域 形参 变量形参 nn: Itp c <444> ainfp t 10 type:

  8. j: itp v l+1: offj a: ainfp v l: 101 b: ainfp v l: 111 rtype: rinfp t 2 i: itp v l+1: offi

  9. rtp v l: 122 y: i r b a d low up ctp clen ainfp: a 1 10 rtp 1 IDE OFF FTP rinfp: d i 0 itp j 1 itp x: rtp v l: 121

  10. 3.设当前层数和区距分别为l和off, 且有函数说明首部: FUNCTION f(A : atype; VAR B: atype; VAR X: real): integer 试写各标识符的语义字,其中atype见题2。

  11. (l,off) FUNCTION f( (l+1,4) A : atype; (l+1,14)VAR B:atype; (l+1,15)VAR X:real (l+1,16) ): integer (l+1,16+l+2)

  12. 4、要求在下面括号中写上相应l(层数)和区距(off):4、要求在下面括号中写上相应l(层数)和区距(off): (,) PROCEDURE g(A: atype; ( ,) VAR B: atype; ( , ) VAR X : real( , )) (,).

  13. 解: (l,off) PROCEDURE g ( (l+1, 4) A: atype (l+1,14) VAR B :atype; (l+1,15) VAR X: real (l+1,16) ) (l+1,16+l+2)

More Related