Presentation is loading. Please wait.

Presentation is loading. Please wait.

劉庠宏、林合治編著 國立高雄大學應用數學系 2005年3月1日

Similar presentations


Presentation on theme: "劉庠宏、林合治編著 國立高雄大學應用數學系 2005年3月1日"— Presentation transcript:

1 劉庠宏、林合治編著 國立高雄大學應用數學系 2005年3月1日
如何利用本系Linux 主機群編譯與執行程式 劉庠宏、林合治編著 國立高雄大學應用數學系 2005年3月1日

2 What are the “Number Machines (NMs)”?
zero.math.nuk.edu.tw ~nine.math.nuk.edu.tw 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

3 How to log in the NMs? Host Name: zero.math.nuk.edu.tw~nine.math.nuk.edu.tw User Name: Same as 高大應數學習資源網 user name Default password: redhat 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

4 How to log in the NMs? (cont.)
利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

5 How to log in the NMs? (cont.)
New terminal/file transfer windows terminal windows New File transfer windows 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

6 The Secure Shell Client (SSH) terminal windows view
Menu Mouse-enabled scroll bar Editing windows Status bar 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

7 The file transfer windows view
Menu Mouse-enabled scroll bar files on number machine Files on your computer Message of transfer Status bar 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

8 How to upload/download files to/from the NMs?
利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

9 Basic Linux commands 顯示目前的目錄: pwd Ex: more hello.c
更改密碼:yppasswd(passwd) 變換目錄:cd Ex: cd math (到math這個目錄) 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

10 Basic Linux commands (cont.)
到根目錄: cd / 建立一個新目錄: mkdir Ex: mkdir math (建立math這個目錄) 刪除一個空目錄:rmdir Ex: rmdir math (刪除math這個目錄) 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

11 Basic Linux commands (cont.)
列出資料夾檔案: ls 複製檔案: cp (來源檔) (目的地) Ex: cp hello.c math (複製hello.c到math資料夾) 刪除檔案:rm (檔名) Ex: rm hello.c (刪除hello.c) 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

12 Basic Linux commands (cont.)
查詢指令用法: man (指令名稱) 按q離開 到上一層目錄: cd .. 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

13 How to edit codes by Emacs?
啟動 emacs: emacs 結束 emacs: Ctrl-x Ctrl-c 取消執行: Ctrl-g 開啟新檔案: Ctrl-x Ctrl-f 輸入檔名 例如: Ctrl-x Ctrl-f hello.c 刪除游標目前指的/後面的字: Ctrl-d 存檔: Ctrl-s 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

14 Source code #include<stdio.h> <-----我是標頭檔 int main() {
// 主程式碼區塊 return 0; } 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

15 動手寫程式吧 #include<stdio.h> int main() { Return 0; }
程式目的:列印出 “hello!!world!!” 的字樣 #include<stdio.h> int main() { Return 0; } Printf(“Hello! World!!\n”); 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

16 程式說明 Printf(“列印出字樣”); :列印出字樣 Printf(“\n”); :換下一行 利用本系Linux主機編譯程式
高大應數課程講義 (2005/3)

17 編譯程式與執行程式 C Language: [b45_chad@five b45_chad]$ gcc hello.c
-o hello b45_chad]$ ./hello Hello! World!! 執行結果 C++ Language: b45_chad]$ g++ hello.cpp –o hello b45_chad]$ ./hello Hello! World!! 執行結果 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)

18 編譯程式與執行程式(計時) 計時:time ./(執行檔) Ex: time ./hello (計算非常粗略,不準確!)
C Language: b45_chad]$ ./hello Hello! World!! 計時:time ./(執行檔) Ex: time ./hello (計算非常粗略,不準確!) Hello! World!! real 0m4.193s user 0m0.040s sys m0.040s 利用本系Linux主機編譯程式 高大應數課程講義 (2005/3)


Download ppt "劉庠宏、林合治編著 國立高雄大學應用數學系 2005年3月1日"

Similar presentations


Ads by Google