1 / 5

程式設計實習第十四次上課

程式設計實習第十四次上課. 傅榮勝. 期末上機考注意事項. 時間: 6/19 星期六 中午 1:10 ~3:00 地點: 6408 與 6402 ,請參考教室外座位表 總成績將於 6/23 星期三早上 10:00 前公佈於老師研究室前。 對成績有疑義者可於 6/22 星期三 11:00~11:50 至老師研究室查詢。. 講解期中小考 a 卷. 請寫一個陣列總和函式,其參數為一整數陣列、此陣列的元素個數,而其傳回值為此陣列元素值之總和。 請在主程式中,使用亂數產生一百個 0~100 之整數在於一陣列中,然後呼叫陣列總和函式算出總和印出。

james-rush
Télécharger la présentation

程式設計實習第十四次上課

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. 程式設計實習第十四次上課 傅榮勝

  2. 期末上機考注意事項 • 時間:6/19 星期六中午1:10 ~3:00 • 地點:6408與6402,請參考教室外座位表 • 總成績將於6/23星期三早上10:00前公佈於老師研究室前。 • 對成績有疑義者可於 6/22星期三11:00~11:50至老師研究室查詢。 Jung-Sheng Fu, DEE, NUU, ROC

  3. 講解期中小考 a 卷 • 請寫一個陣列總和函式,其參數為一整數陣列、此陣列的元素個數,而其傳回值為此陣列元素值之總和。 • 請在主程式中,使用亂數產生一百個0~100之整數在於一陣列中,然後呼叫陣列總和函式算出總和印出。 • 請注意:陣列總和函式使用遞迴方式才能得100分,用非遞迴為90分! Jung-Sheng Fu, DEE, NUU, ROC

  4. 講解期中小考 b 卷 • 請寫一個棒打老虎雞吃蟲的小遊戲,讓user輸入0,1,2,3,4 分別代表蟲、雞、老虎、棒、和不玩了。 • 其規則是棒贏老虎,老虎贏雞,雞贏蟲,蟲贏棒,老虎和蟲平手,棒和雞平手。 • 然後電腦用亂數產生一個0到3的值,代表電腦所出為何,並且印出輸贏的結果:例如:「你出雞,電腦出蟲,你輸」。 • 請持續進行此一遊戲,直到user輸入4停止為止。 Jung-Sheng Fu, DEE, NUU, ROC

  5. 範例:二元搜尋法 • 請寫一個函式search可以在最短的時間內找到已排序陣列中某值的駐標,若陣列中無此值則傳回-1。其原型為 • 遞迴:int search(int a[ ], int left, int right, int key) Jung-Sheng Fu, DEE, NUU, ROC

More Related