2009/11/26 Quiz 學號: 姓名: Closed book. ___________ _____________ *** 請依序作答於此頁, 不夠寫就寫到背面 25%(I) Basic Computer Concept. 每子題 5分. (a) What is Y2k38 problem? Explain why we might have Y2k38 problem. (b) What is the purpose of static Global variable? Explain it with example. (c) Explain "Big Endian" and "Little Endian" with examples. (d) Regarding 亂數, what does the acronym "PRNG" stands for? (寫出這 PRNG 的英文全名), and explain why we call it "Pseudo"? (e) Write a C statement which will give an integer 亂數 [15, 31] in the int variable k. (注意 [15, 31] 意思是包括 15 和 31 ) 15%(II)關於 Hanoi tower, 假設已經寫好 void moveOne(int px, int py, int n); 代表把第 n 個碟子從 Peg px 搬到 peg py: void moveOne(int px, int py, int n) { printf("Move %d-th disk from peg-%c --> to peg-%c\n",n, px, py); } 10% (a)寫出recursive 函數 hanoi(int n, int px, int py, int ptemp); 以便 hanoi(k, 'A', 'C', 'B');可把peg 'A' 上的 k 個碟子搬到peg 'C', peg 'B' 為臨時使用的 peg (柱子). 5% (b)寫出 hanoi(3, 'G', 'Y', 'T'); 的結果. (注意參數!) 35%(III)關於平均值與標準差, 假設有 n 個資料, 依照定義, Variance變異數 = (每個資料 - 平均) 的平方 除以 n Standard Deviation 標準差 = 變異數的平方根 台北車站廣場打算設置一台體重統計機,任何人站上去後立刻顯示其體重 並且立即顯示以下統計: n : 共已多少人在此量過體重 Average : 平均體重 STD : 這 n 人的體重標準差 20% (a)顯然, 我們需要一個可以同時算出平均與變異數的公式: Variance變異數 = (各資料的平方和 - 各資料和的平方/n ) / n 請從前述 Variance 的定義逐步導出以上這個公式. 15% (b)所以, 只要記住 n, 平方和 以及 和(sum), 就可算出變異數; 請為台北車站寫一個程式可以每次讀入一個double實數, 然後印出到目前為止的 n, Average, 以及 STD, 程式不可以因輸入而當掉(用fgets搭配 atof)! 若輸入負數則結束! 35%(IV)請討論關於 NIM 遊戲之贏的策略, 不需寫程式 ! 15% (a)若只有兩堆, 贏的策略為何? 必須講最簡單的方式! 不可提到任何運算! 且要考慮拿最後一個贏與拿最後一個輸! 20% (b)若有三堆或更多, 說明贏的策略, 要考慮拿最後一個贏與拿最後一個輸!