1 / 9

程式設計技巧 數字處理

程式設計技巧 數字處理. Ren-Jie Wang, 王 仁 傑 , Ph.D. rjwang@ntit.edu.tw 課程網頁 : http://home.scs.ntit.edu.tw/rjwang/. 重點提要. 1 數字 處理相關函數 2 常見的數字處理工作 3 實例練習. 1 數字處理相關函數. 『 工欲善其事,必先利其器 』 。常見的文字處理工作都有相對應的內建函數可以使用,不必事事無中生有,可以降低程式設計工作的難度,提高效率。. 1 數字處理相關函數. 1 數字處理相關函數. 5. 2常見的 數字 處理工作. 轉成整數 四捨六入五成雙

xuan
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. 程式設計技巧 數字處理 Ren-Jie Wang,王 仁 傑, Ph.D. rjwang@ntit.edu.tw 課程網頁: http://home.scs.ntit.edu.tw/rjwang/

  2. 重點提要 • 1數字處理相關函數 • 2常見的數字處理工作 • 3實例練習

  3. 1數字處理相關函數 • 『工欲善其事,必先利其器』。常見的文字處理工作都有相對應的內建函數可以使用,不必事事無中生有,可以降低程式設計工作的難度,提高效率。

  4. 1數字處理相關函數

  5. 1數字處理相關函數 5

  6. 2常見的數字處理工作 • 轉成整數 • 四捨六入五成雙 • Cint(), math.Round() • 四捨五入 (到小數下第n位) • Int( x *10^n+0.5)/10^n • 其他 • Int(), fix(), math.Truncate(), math.Ceiling, math.Floor() • 亂數模擬 • 丟銅板、卜卦、骰子、撲克牌 • 任意m~n區間的整數 • Int(rnd*(n-m+1)+m

  7. 2常見的數字處理工作 • 因數問題 • 求最大公因數GCD • 若A>B, 則有GCD(A,B)=GCD(B, A mod B) • 利用遞迴函數製作 GCD • 求最小公倍數lcm • A×B = GCD×lcm • 已知GCD, 則lcm亦可求出。 • 質數問題 • 找出n之所有質因數 • N 不大的時候,直接將  試除一遍。 • 質因數分解

  8. 2常見的數字處理工作 • 排序、搜尋 • 利用Array類別所提供的方法 • 矩陣的運算 • 矩陣的加、減、乘 • 大數運算 • 以陣列來存大數的每一位數字 • 手怎麼算,程式就怎麼寫

  9. 3 實例練習 • 高中生程式解題系統 ZeroJudge之分類題庫 • a007: 判斷質數 • a010: 因數分解 • a015: 矩陣的翻轉、 d481: 矩陣乘法 • a021: 大數運算 • a024: 最大公因數(GCD) • a034: 二進位制轉換 • a038: 數字翻轉 • a032: 階乘運算(大數)

More Related