發表文章

目前顯示的是 2007的文章

hw8

7.14 Given the two functions (in C syntax):     int cube (int x) { return x*x*x; }     int sum (int x, int y, int z) { return x + y + z; } describe the process of normal order evaluation of the expression sum(cube(2), cube(3), cube(4)), and compare it to applicative order evaluation. In particular, how many additions and multiplications are performed using each method? 7.32  Describe the effect of the FORTRAN "spaghetti code" of Figure 7.6, Section 7.4. Write c/c++ statements without GOTOs that equivalent it. If not, explain why not. Figure 7.6      IF (X.GT.O) GOTO 10     IF (X.LT.O) GOTO 20     X = 1     GOTO 30 10  X= X + 1     GOTO 30 20  X= -X     GOTO 10 30  CONTUNUE

[OS]hw4題目

有兩台火車個別運行在交錯於兩點的兩條軌道上 -------------------------------------------- 火車    長度     鐵軌長   交錯點位於 A           10           34           7        23 B           12           43           9        19  -----------------------------------------  兩輛火車都從位置 0 開始 速度  一格/秒 停止條件:兩輛火車都走完100格 題目 限制:  以兩條thread時做                     兩條火車不能同時進入軌道交叉點 系統限制: linux 上可執行  output格式: 每步驟印出兩行 分別代表兩軌道上的情形                         鐵軌: ........                         交叉口:  x                        火車A: >>>                        火車B: === EX: >>>>>>>X...............X.......>>> ====.....X.........X...............========