看板 Grad-ProbAsk 關於我們 聯絡資訊
清大資應101年計算機概論第三部分第2題 Suppose the abstract data type stackType was defined as follows: define type StackType to be { int StackEntries[20]; int StackPointer = 0; procedure push(Value) { StackEntries[StackPointer] <- Value; StackPointer <- StackPointer + 1; } } (i) What would be the value of the variable of StackPointer associated with Stack after executing the following statement? StackType Stack; (ii) Then,what would be the value of StackPointer associated with Stack after executing the following statement? Stack.push(5); 我剛看了半天,還是搞不太懂第一提那個指令會對StackPointer會造成什麼影響 那不是只是宣告一個新的Stack嗎? 有大大可以幫小弟指點迷津嗎? 謝謝~~~ PS:按照我這個想法算出來第一題是 0,第二題是 1。不知道對不對 > < -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.114.66.135 ※ 文章網址: https://www.ptt.cc/bbs/Grad-ProbAsk/M.1453373225.A.1A3.html ※ 編輯: dinghaipi (140.114.66.135), 01/21/2016 18:48:41
jerry031181: 答案應該是你那樣沒錯啦~ 01/21 23:50
喔喔好的謝謝~~ ※ 編輯: dinghaipi (140.114.86.84), 01/22/2016 11:19:09