NTNU 程式設計(一)
NTNU
CSIE
必修
Programming(I)
非管理員但願意加入筆記編寫的
可在此區留言或直接跟Admin們要Write權限 給帳號(profile裡@的那串)或email皆可 所有登入帳號都可以在留言區發言 有問題可以直接留言區留
修正注意事項 麻煩發現觀念錯誤的先以
這種方式修改並標上日期提醒其他人 錯字類的直接修改即可
Win10 (Mac 沒裝過會怕…還是乖乖用VM就好)
更多可看CTF Note
printf 的 "f" 代表 format
gcc 在沒有 include stdio.h 時也可以成功編譯 printf
gcc 是給 C 用的,C++ 要用 g++
先建一個檔名為"GNUmakefile"or"Makefile" or "makefile"的檔案
裡面都可以寫要執行的指令,之後還會有連結檔案。
RTFM:read the Fucking manual
STFG:search the Fucking google
請用C寫出 0.5 + 2.7 * 3.2 - 6.8 / 2.4 的答案
意思 | 宣告 | 備註 | |
---|---|---|---|
%d | 十進位整數 | int | decimal int |
%i | 整數 | int | %d and %i are synonymous for output, but are different when used with scanf() for input where using %i will interpret a number as hexadecimal if it's preceded by 0x, and octal if it's preceded by 0 |
%f | 浮點數 | float | 如果寫成 %.xf 會只顯示到小數點下第x位,並四捨五入 |
%u | 無號整數 | unsigned int | 如果題目不會遇到負數 然後最大範圍到232-1的時候可以用 |
%c | 字元 | char | |
%s | 字元陣列 | char* | |
%% | 列印% | ––– |
只有0才不會做if後面的程式
if只會執行底下的一個指令,要執行多個指令要用{}包起來
in math | in C |
---|---|
< | < |
> | > |
≤ | <= |
≥ | >= |
= | == |
≠ | != |
∪ | || |
∩ | && |
(條件) ? (若成立則執行) : (不成立則執行)
Only two possible values: ture false
bool 的大小為 1 byte
bool 可以設為 true false 以外的東西(-127~127)
lower camel case 駝峰命名法
Example:TotalGrade
i++ use the current value first
++i use the value after ++
首先開一個資料夾
$ mkdir hello
並進入該資料夾
$ cd hello
建立一個新的 Repository
$ git init
顯示目前Git的狀態:$ git status
使Git來追蹤我們的檔案:$ git add <檔案>
取消目前追蹤檔案版本:$ git rm --cached
將此次追蹤的檔案作註解:
$ git commit
$ git commit -m "輸入此次變更記錄“
修改當前commit文字:
$ git commit --amend
查看commit的歷史紀錄:
$ git log
$ git log --stat
$ git log -p
從主要 branch 再開出一條新的 branch 來做,這支新開的 branch 會帶著原本 branch 目前狀態,
當完成所要開發的新功能或是 bug 修正後確認沒問題就再把它合併回主 branch
開新 branch:
$ git branch <名稱>
列出所有branch:
$ git branch
切換至其他branch:
$ git checkout <名稱>
切換至master branch:
$ git checkout master
將檔案傳輸至伺服器:
$ git remote add origin <目標伺服器>
$ git push –u origin master
至伺服器中將檔案下載回本機更新:
$ git pull --rebase
Author:施衡
Author:高仔
Never reinventing whe wheel.
Search brfore you develop
gcc -c main.c
gcc -c mymax.c
gcc main.o mymax.o
每個程式都有屬於自己的.o可以用(資本主義)
每個程式共用一個.o(共產主義)
Array is a way to store lots of data items of "the same type".
陣列是從0開始數 -> int32_t num[20] 的最後一項是 num[19]
define is a preporcessor directive, not a C statement.
將陣列傳至函式裡時,不用設定陣列大小。
Passing a 2D array into a funtion, you must set bounds except the first:
funtion( array[][bounds] )
指標 = 用來儲存記憶體位址的變數
pointer + 1 會相當於 pointer 前進一個元素,如 int32_t *每次就是前進4個 bytes
而用 void *宣告時則是前進1個 byte
建立函式指標
在函式裡使用函式指標
Malloc向電腦要記憶體
Calloc向電腦要記憶體(自帶初始化為0)
pointer of pointer, allocate memory in a function, 2D-array
char = int8_t (Ascii code)
Sample code will release after due.
Due: 2019.10.13 PM 11:59
Problem
Due: 2019.10.20 PM 11:59
Problem
Due: 2019.11.03 PM 11:59
Problem
Problem
Due: 2019.12.01 PM 11:59
Problem
Due: 2019.12.15 PM 11:59
Problem
Due: 2020.01.05 PM 11:59
Problem
Problem