Microsoft Word finalSol.doc

Size: px
Start display at page:

Download "Microsoft Word finalSol.doc"

Transcription

1 1041 國立台灣海洋大學資訊工程系 1C 程式設計期末考參考解答 姓名 : 系級 : 學號 : 1/8 105/01/06 ( 三 ) 考試時間 :13:20 16:20 請儘量回答, 總分有 122, 看清楚每一題所佔的分數再回答考試規則 :1. 不可以翻閱參考書 作業及程式 2. 不可以使用任何形式的電腦 ( 包含手機 計算機 相機以及其它可運算或是連線的電子器材 ) 3. 請勿左顧右盼 請勿交談 請勿交換任何資料 試卷題目有任何疑問請舉手發問 ( 看不懂題目不見得是你的問題, 有可能是中英文名詞的問題 ) 最重要的是隔壁的答案不見得比你的好, 白卷通常比錯得和隔壁一模一樣要好 4. 提早繳卷同學請直接離開教室, 請勿逗留喧嘩 5. 違反上述任何一點之同學一律依照學校規定處理 6. 繳卷時請繳交簽名過之試題卷及答案卷 1. 有下列的使用者自訂結構型態 struct data char name[10]; // 姓名 char gender; // 性別 char mathscore; // 數學成績 ; a. [2] 請定義一個這種結構型態的指標 students struct data *students; b. [2] 請用 malloc() 函式配置 100 個 struct data 型態元素的陣列, 記錄在 students 變數裡 students = (struct data *) malloc(sizeof(struct data)*100); c. [4] 請檢查上面步驟是否有配置成功, 有的話請用一個迴圈將所有 100 個學生的 name 欄位的資料都清除為空字串 if (students!=null) for (int i=0; i<100; i++) students[i].name[0] = 0; d. [2] 請用 free() 函式釋放上面用 malloc() 取得的記憶體 free(students); e. [2] 請問要使用 malloc() 和 free() 需要引入哪一個標頭檔案? stdlib.h 或是 malloc.h 2. 在 stdlib.h 裡面有一個 qsort() 的工具程式, 它會用 快速排序法 來把一整個陣列裡的資料依照指定的比較大小方法來排順序, 例如上題中 100 個學生的 students 陣列, 就可以用 name 欄位來排大小 ( 假設 name 欄位裡面都是英文的資料 ), 程式如下 : #include <stdlib.h> #include <string.h> // 使用 strcmp(str1, str2) 函式, str1 < str2 則函式回傳 -1, str1 == str2 則回傳 0, 否則回傳 1 struct data

2 ; int compare(const void *a, const void *b) return strcmp((*(struct data *)a).name, (*(struct data *)b).name); int main() qsort(students, 100, sizeof(struct data), compare); a. [3] 請解釋上面 compare() 函式裡 a, b 兩個指標所指的東西對 qsort() 來說代表什麼資料 在 qsort() 函式排序時, 需要以一個區塊為單位來比較大小, 如果需要的話交換其順序, 例如上面程式裡是大小為 sizeof(struct data) 的連續記憶體為單位, 也就是以一個完整的結構為單位, 每次 qsort() 需要比對兩塊資料的大小時, 它就呼叫 compare(), 把兩塊資料的記憶體位址傳遞進來, 其中 a 就是第一塊的記憶體位址, b 是第二塊的記憶體位址 b. [3] 請解釋 compare() 函式裡為什麼不能寫 (*a).name 而要寫 (*(struct data *)a).name 但是 qsort() 並不曉得使用者的 struct data 的結構型態, qsort() 是一個函式庫裡已經寫好的函式, 所以它只能傳遞 const void * 型態的記憶體位址, compare() 函式裡面需要自己去告訴編譯器這個記憶體位址是 struct data * 的型態, 如此編譯器才允許程式裡去存取 name, gender, mathscore 等欄位, 也就是 *(struct data*)a 其實代表一個結構變數, (*(struct data*)a).name 就是它的 name 欄位, 也可以寫成 ((struct data *)a)->name c. [3] 上面是依照字典順序由小到大排序, 請問怎麼改成由大到小排序 int compare(const void *a, const void *b) return strcmp((*(struct data *)b).name, (*(struct data *)a).name); d. [6] 如果要改成主要是用 mathscore 由大到小排序, 當成績相等時才用姓名由小到大排序該怎麼改 int compare(const void *a, const void *b) struct data *pa = (struct data *) a, *pb = (struct data *) b; if (pa->mathscore == pb->mathscore) return strcmp(pa->name, pb->name); return pb->mathscore - pa->mathscore; 3. 所謂的迴文 (Palindrome) 是指一個字串去掉標點符號和空白以後由前面看和後面看是一模一樣的字串 ( 大小寫視為相同 ), 例如 : "A man, a plan, a canal, Panama!", "Amor, Roma", "race car", "taco cat", "Was it a car or a cat I saw?", 或是 "No 'x' in Nixon", 請依照下面要求撰寫程式來檢查一個字串是不是迴文 ( 如果一個字串中沒有任何大寫或是小寫的英文, 視為不是迴文 ) a. [15] 首先請運用 gets() 由鍵盤讀取一個不超過 100 個字元的字串到字元陣列中, 然後請寫一小段程式把不是 'a'~'z' 也不是 'A'~'Z' 的都去掉, 並把所有字母轉換成大寫字母, 請寫一個迴圈判斷是不是迴文, 執行結果如下 輸入 : A man, a plan, a canal, Panama!<enter> 輸出 : 是迴文 2/8

3 輸入 : No 'y' in Nixon<enter> 輸出 : 不是迴文 #include <stdio.h> #include <string.h> int main() int i, len, lenoriginal; char buf[101]; gets(buf); lenoriginal = strlen(buf); for (i=len=0; i<lenoriginal; i++) if ((buf[i]>='a')&&(buf[i]<='z')) buf[len++] = buf[i]; if ((buf[i]>='a')&&(buf[i]<='z')) buf[len++] = buf[i]-'a'+'a'; buf[len] = 0; for (i=0; i<len/2; i++) if (buf[i]!=buf[len-i-1]) break; if ((len<=0) (i<len/2)) b. [15] 請修改上題判斷迴文的部份 ( 不需要寫取讀字串, 刪除標點與轉換大小寫 ), 撰寫一個遞迴函式 int ispalindrome(int start, int end, char str[]) 來判斷 ( 回傳 1 代表是迴文, 0 代表不是迴文, 請在 main() 裡面列印 ) int ispalindrome(int start, int end, char buf[]); int main() if (!ispalindrome(0, strlen(buf)-1, buf)) printf(" 是迴文 "); int ispalindrome(int start, int end, char buf[]) if (start >= end) if (buf[start]!= buf[end]) return ispalindrome(start+1, end-1, buf); c. [5] 請修改上題的遞迴函式成為 int ispalindrome(int size, char str[]), 其中 size 代表需要判 3/8

4 斷字串的長度 int ispalindrome(int size, char str[]); int main() if (!ispalindrome(strlen(buf), buf)) printf(" 是迴文 "); int ispalindrome(int size, char str[]) if (size <= 1) 5 SATOR if (str[0]!= str[size-1]) AREPO TENET OPERA return ispalindrome(size-2, str+1); ROTAS 右圖的資料代表二維的迴文, 第一列的數字 N 代表接下來是 NxN 的迴文, 可以看到迴文的第五列是第一列反轉過來的字串, 第四列是第二列反轉過來的字串, 第三列是自己反轉過來的字串, 如果是偶數列的話就不會有自己反轉的這一列 ), 假設輸入都是 'A'~'Z' 之間的字母, 每一列最多只有 20 個字元 d. [15] 請用 gets() 配合 sscanf() 讀入這些資料, 用迴圈撰寫判斷二維迴文的程式 #include <stdio.h> int main() int i,j, size; char buf[21], matrix[20][21]; gets(buf); sscanf(buf, "%d", &size); for (i=0; i<size; i++) gets(matrix[i]); for (i=0; i<(size+1)/2; i++) for (j=0; j<size; j++) if (matrix[i][j]!= matrix[size-1-i][size-1-j]) printf(" 不是迴文 \n"); e. [10] 請撰寫遞迴函式 int ispalindrome2d(char matrix[][21], int nrow, int ncol) 來判斷 4/8

5 #include <stdio.h> int ispalindrome2d(char matrix[][21], int nrow, int ncol); int main() int size; char matrix[20][21]; if (!ispalindrome2d(matrix, size, size)) int ispalindrome2d(char matrix[][21], int nrow, int ncol) int j; if (nrow <= 0) for (j=0; j<ncol; j++) if (matrix[0][j]!= matrix[nrow-1][ncol-1-j]) return ispalindrome2d(&matrix[1], nrow-2, ncol); 這個遞迴函式也有使用迴圈, 就好像在寫迷宮的遞迴程式, 在每一次函式執行過程中也會用一次的迴圈, 主要是考慮整個函式的可讀性 ; 也可以把它寫成完全沒有迴圈的形式, if (!ispalindrome2d(matrix, 0, size*size-1, size)) int ispalindrome2d(char matrix[][21], int start, int end, int size) if (start >= end) if (matrix[start/size][start%size] == matrix[end/size][end%size]) return ispalindrome2d(matrix, start+1, end-1, size); 這個函式基本上也就是把整個二維陣列拉直了來看而已, 或是 if (!ispalindrome2d(matrix, 0, 0, size)) int ispalindrome2d(char matrix[][21], int row, int col, int size) if (row*size+col >= size*size/2) 5/8

6 if (matrix[row][col] == matrix[size-1-row][size-1-col]) return ispalindrome2d(matrix, row+(col+1)/size, (col+1)%size, size); 還有很多其它的寫法, 沒有標準答案 4. 三個柱子的河內塔遞迴函式範例如下 01 void move(char from_peg, char to_peg, char aux_peg, int ndisks) 02 if (ndisks == 1) 03 printf("1 %c %c\n", from_peg, to_peg); move(from_peg, aux_peg, to_peg, ndisks - 1); 06 printf("%d %c %c\n", ndisks, from_peg, to_peg); 07 move(aux_peg, to_peg, from_peg, ndisks - 1); a. [5] 請寫出函式呼叫 move('a', 'C', 'B', 3) 在螢幕上的輸出 1 A C 2 A B 1 C B 3 A C 1 B A 2 B C 1 A C b. [5] 這個函式移動的次數一定是最少的, 如果是只有一個碟子時, 只要移動 a 1 = 1 次, 如果只有兩個碟子時, 只要移動 a 2 = 3 次,, 如果有 n 個碟子時, 你知道最大的碟子至少要移動 1 次, 但是在移動它之前, 要把上面 n-1 個碟子都先移到輔助的柱子上 ( 由 from_peg 到 aux_peg), 那麼最少要移動 a n-1 次, 然後才能移動最大的碟子 ( 由 from_peg 到 to_peg), 然後再把輔助的柱子上面的 n-1 個碟子移到目標柱子上, 又需要 a n-1 次, 總共需要移動 a n = 2 a n 次, 請寫出 a n 的通式 ( 用 n 表示出來 ) a 1 = 1, a 2 = 1 + 2, a 3 = , a 4 = ,, a n = 2 n -1 c. [5] 如果我們禁止 A 與 C 兩個柱子之間直接搬移, 也就是說要由 A 搬到 C 只能先由 A 搬到 B 然後再由 B 搬到 C, 所以最大的碟子 ( 第 n 個 ) 要由 A 搬到 C 至少要搬兩次, 在過程裡還要先把 n-1 個碟子由 A 先搬到 C, 把最大的碟子由 A 搬到 B, 再把 n-1 個碟子由 C 搬回 A, 把最大的碟子由 B 搬到 C, 再把 n-1 個碟子由 A 搬到 C, 參考題 b. 請寫出最少需要移動幾次 b n 的 recursion 表示法 b n = 3 b n (b 1 = 2, b 2 = 2 (1 + 3), b 3 = 2( ), b 4 = 2( ),, b n = 3 n -1) d. [10] 請修改上面的 move() 函式來完成題 c. 的遞迴程式右圖是一個簡單的執行範例 move('a', 'C', 'B', 2); #include <stdio.h> void move(char from_peg, char to_peg, char aux_peg, int ndisks); 6/8 1 A B 1 B C 2 A B 1 C B 1 B A 2 B C 1 A B 1 B C

7 int main() int ndisks; printf(" 請輸入碟片數 : "); scanf("%d", &ndisks); move('a', 'C', 'B', ndisks); void move(char from_peg, char to_peg, char aux_peg, int ndisks) if (ndisks == 1) if (aux_peg=='b') printf("1 %c %c\n", from_peg, aux_peg); printf("1 %c %c\n", aux_peg, to_peg); printf("1 %c %c\n", from_peg, to_peg); if (aux_peg=='b') move(from_peg, to_peg, aux_peg, ndisks - 1); printf("%d %c %c\n", ndisks, from_peg, aux_peg); move(to_peg, from_peg, aux_peg, ndisks - 1); printf("%d %c %c\n", ndisks, aux_peg, to_peg); move(from_peg, to_peg, aux_peg, ndisks - 1); move(from_peg, aux_peg, to_peg, ndisks - 1); printf("%d %c %c\n", ndisks, from_peg, to_peg); move(aux_peg, to_peg, from_peg, ndisks - 1); 5. [10] 實習裡寫了快速排序法, 基本的架構如下 01 void quick_sort(int array[], int istart, int iend) 02 if (iend-istart > 1) 03 int pivot = place_midst(array, istart, iend); 04 quick_sort(array, istart, pivot-1); 05 quick_sort(array, pivot+1, iend); if (iend-istart == 1) 08 if (array[istart]>array[iend]) swap(array, istart, iend); int place_midst(int array[], int istart, int iend) // 將 array[istart] 放到正確位置 array[pivot] 11 // 而且比較小的放在前半, 大於或是等於的放在後半 12 7/8

8 假設 place_midst() 函式是可以正常運作的, 它會回傳那個正確的位置 pivot, 你現在需要修改上面的 quick_sort() 函式變成 int find_kth_element(int array[], int istart, int iend, int k), 我們只需要找到由小到大算起來前 k 個元素就好了, 函式回傳第 k 個元素的數值, 請用遞迴的二分法來完成例如下面程式可以印出前 3 個元素 int array[] = 3, 1, 4, 9, 6, 2, 7, kth, n = 7; kth = find_kth_element(array, 0, n-1, 3); for (int i=0; i<2; i++) printf("%d ", array[i]); printf("%d\n", array[2]); int find_kth_element(int array[], /* input/output - array to sort */ int istart, /* input - starting element of the array to consider */ int iend, /* input - ending element of the array to consider */ int k) /* find the k-th non-decreasing element */ if (iend-istart > 1) int pivot = place_midst(array, istart, iend); if (pivot==k-1) return pivot; if (pivot>k-1) return find_kth_element(array, istart, pivot-1, k); return find_kth_element(array, pivot+1, iend, k); if (istart==k-1) return istart; // if (iend==k-1) return iend; 8/8

C++ 程式設計

C++ 程式設計 C C 料, 數, - 列 串 理 列 main 數串列 什 pointer) 數, 數, 數 數 省 不 不, 數 (1) 數, 不 數 * 料 * 數 int *int_ptr; char *ch_ptr; float *float_ptr; double *double_ptr; 數 (2) int i=3; int *ptr; ptr=&i; 1000 1012 ptr 數, 數 1004

More information

Microsoft PowerPoint - C_Structure.ppt

Microsoft PowerPoint - C_Structure.ppt 結構與其他資料型態 Janet Huang 5-1 結構的宣告 struct 結構名稱 struct 結構名稱變數 1, 變數 2,, 變數 m; struct 結構名稱 變數 1, 變數 2,, 變數 m; student; student; 5-2 1 結構變數初值的設定 struct 結構名稱 struct 結構名稱變數 = 初值 1, 初值 2,, 初值 n student="janet","1350901",100,95

More information

untitled

untitled CHAPTER 02 2 CHAPTER 2-1 2-4 2-2 2-5 2-3 2-6 2-1 2-1-1 2-2 02 int A[3] = {10, 20, 30; A[0] 10 A[1] 20 A[2] 30 int *pa[3], A[3]; C 3 pa pa[0]pa[1]pa[2] 3 A A[0]A[1]A[2] 3 A A[0] A + i A[i] A + i &A[i]*(A

More information

碩命題橫式

碩命題橫式 一 解釋名詞 :(50%) 1. Two s complement of an integer in binary 2. Arithmetic right shift of a signed integer 3. Pipelining in instruction execution 4. Highest and lowest layers in the TCP/IP protocol suite

More information

Microsoft Word - ACL chapter02-5ed.docx

Microsoft Word - ACL chapter02-5ed.docx 第 2 章神奇的質數 2.1.1 什麼是質數 1 1 1 打下好基礎 - 程式設計必修的數學思維與邏輯訓練 1 1 0 10 2 3 5 7 4 6 8 9 10 4 10000 1229 1000 168 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131

More information

Microsoft Word FinalSolution.doc

Microsoft Word FinalSolution.doc 1071 NTOUCSE 程式設計 1C 期末考參考答案 1 / 7 108/01/08 ( 二 ) 1. 請根據下列要求撰寫一個 函式, 判斷傳入的 long long 型態正整數 number 是否是 2 的次方數 (1 算是 2 0 ), 是的話請傳回 1, 不是的話請傳回 0 a. [5] 請運用迴圈撰寫 while (number%2==0) number /= 2; // 把所有 2 的因數除掉,

More information

Microsoft PowerPoint - C-Ch10.ppt

Microsoft PowerPoint - C-Ch10.ppt 了解陣列元素的位址 陣列 指標的應用 10-1 陣列與指標的關係 可以使用位址運算子 (&) 來查詢陣列中各個元素的位址 &test[0] 這行表示陣列最前面元素的位址 &test[1] 這行表示陣列第二個元素的位址 關於陣列名稱的機制 陣列名稱可以表示陣列最前面元素的位址 #include int main(void) int test[5] = 80,60,55,22,75;

More information

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1 C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 月 3 日 1 1 INPUTOUTPUT 1 InputOutput 题目描述 用 cin 输入你的姓名 ( 没有空格 ) 和年龄 ( 整数 ), 并用 cout 输出 输入输出符合以下范例 输入 master 999 输出 I am master, 999 years old. 注意 "," 后面有一个空格,"." 结束,

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 9 [P.11] : Dev C++ [P.12] : http://c.feis.tw [P.13] [P.14] [P.15] [P.17] [P.23] Dev C++ [P.24] [P.27] [P.34] C / C++ [P.35] 10 C / C++ C C++ C C++ C++ C ( ) C++

More information

C 1

C 1 C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc 2 5 8 11 0 13 1. 13 2. 15 3. 18 1 23 1. 23 2. 26 3. 28 2 36 1. 36 2. 39 3. 42 4. 44 5. 49 6. 51 3 57 1. 57 2. 60 3. 64 4. 66 5. 70 6. 75 7. 83 8. 85 9. 88 10. 98 11. 103 12. 108 13. 112 4 115 1. 115 2.

More information

プログラムの設計と実現II

プログラムの設計と実現II UNIX C ls mkdir man http://www.tj.chiba-u.jp/lecture/prog2/ Ctrl+x, Ctrl+s ( )..[4]% gcc Wall o hoge hoge.c..[5]%./hoge 1 : 1 2 : 2 3 : 3 4 : 0 6..[6]% (! )..[4]% gcc Wall o hoge hoge.c..[5]%!g gcc Wall

More information

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf (%d, & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf (%d %d 2013 18 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp, Compilation Error cin scanf Time Limit Exceeded 1: A 5 B 5 C 5 D 5 E 5 F 5 1 2013 C 1 # include 2 int main ( void ) 3 { 4 int cases, a, b,

More information

全國各級農會第 2 次聘任職員統一考試試題 科目 : 程式設計類別 : 九職等以下新進人員作答注意事項 : 1 全部答案請寫在答案卷內, 如寫在試題紙上, 則不予計分 2 請以黑色或藍色鋼筆或原子筆書寫, 並以橫式書寫 ( 由左至右, 由上而下 ) 一 選擇題 ( 每題 4 分, 共 40 分 )

全國各級農會第 2 次聘任職員統一考試試題 科目 : 程式設計類別 : 九職等以下新進人員作答注意事項 : 1 全部答案請寫在答案卷內, 如寫在試題紙上, 則不予計分 2 請以黑色或藍色鋼筆或原子筆書寫, 並以橫式書寫 ( 由左至右, 由上而下 ) 一 選擇題 ( 每題 4 分, 共 40 分 ) 全國各級農會第 2 次聘任職員統一考試試題 一 選擇題 ( 每題 4 分, 共 40 分 ) 1. 在 Java 語言中, 請問下列何者資料型別的變數, 所需的儲存空間最少? (a) char (b) float (c) double (d) int 2. 請問下列何者非 C 語言的關鍵字 (key word)? (a) const (b) default (c) dynamic (d) continue

More information

Microsoft PowerPoint - Class5.pptx

Microsoft PowerPoint - Class5.pptx C++ 程式初探 V 2015 暑期 ver. 1.0.1 C++ 程式語言 大綱 1. 大量檔案讀取 & 計算 2. 指標 3. 動態記憶體 & 動態陣列 4. 標準函式庫 (STL) vector, algorithm 5. 結構與類別 2 大量檔案讀取 & 計算 若目前有一個程式將讀取純文字文件 (.txt) 中的整數, 並將該文件中的整數有小到大排序後, 儲存到另外一個新的純文字件中 假設有

More information

Microsoft PowerPoint - 20-string-s.pptx

Microsoft PowerPoint - 20-string-s.pptx String 1 String/ 1.: char s1[10]; char *s2; char s3[] = "Chan Tai Man"; char s4[20] = "Chan Siu Ming"; char s5[]={'h','e','l','l','o','\0'; 0 1 2 3 4 5 6 7 8 9 10 11 12 s3 C h a n T a i \0 M a n \0 printf

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

Microsoft PowerPoint - 10b Design Recursive Solutions.ppt [相容模式]

Microsoft PowerPoint - 10b Design Recursive Solutions.ppt [相容模式] 如何設計遞迴函式 Pei-yih Ting 遞迴函式 遞迴 (recursive) 函式是自己呼叫自己的函式 在呼叫自己之前一定有 if- 一類的選擇判斷敘述, 以避免無窮盡的遞迴呼叫 函式中至少有一條控制路徑不包含遞迴呼叫, 稱為 base case 函式一定有輸入參數, 用來指定所解決問題的規模 例如 : int sum(int n) { if (n==) urn ; urn sum(n-1)

More information

untitled

untitled 1 7 7.1 7.2 7.3 7.4 7.5 2 7.1 VFT virtual 7.1 3 1 1. 2. public protected public 3. VFT 4. this const volatile 4 2 5. ( ) ( ) 7.1 6. no-static virtual 7.2 7. inline 7.3 5 3 8. this this 9. ( ) ( ) delete

More information

C/C++ - 字符串与字符串函数

C/C++ - 字符串与字符串函数 C/C++ Table of contents 1. 2. 3. 4. 1 char C 2 char greeting [50] = " How " " are " " you?"; char greeting [50] = " How are you?"; 3 printf ("\" Ready, go!\" exclaimed John."); " Ready, go!" exclaimed

More information

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2 Chapter 02 變數與運算式 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.2 2.2.1 2.2.2 2.2.3 type 2.2.4 2.3 2.3.1 print 2.3.2 input 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 + 2.4.6 Python Python 2.1 2.1.1 a p p l e b e a r c 65438790

More information

C/C++ - 数组与指针

C/C++ - 数组与指针 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 float candy [ 365]; char code [12]; int states [50]; 2 int array [6] = {1, 2, 4, 6, 8, 10}; 3 // day_mon1.c: # include # define MONTHS 12 int

More information

Microsoft Word C-A卷.docx

Microsoft Word C-A卷.docx 100 學年度資訊學院程式設計會考 (C) 101/05/5 題組 :A 選擇題及填充題, 請在答案卡上作答, 實作題請填寫於答案卷上, 並於實作題上方填寫班級 姓名 學號 一 選擇題題目 1. unsigned char 的最大值 (a) 127 (b) 255 (c) 512 (d) 1023 2. 下列何者為正確的變數名稱? (a) Android (b) C++ (c) I Phone (d)

More information

Microsoft Word cppMidtermSol.doc

Microsoft Word cppMidtermSol.doc 姓名 : 系級 : 學號 : 國立台灣海洋大學資訊工程系 C++ 程式設計期中考解答 98/04/14 考試時間 :10:00 12:00 試題敘述蠻多的, 看清楚題目問什麼, 請針對重點回答, 總分有 120, 請看清楚每一題所佔的分數再回答考試規則 :1. 不可以翻閱參考書 作業及程式 2. 不可以使用任何形式的電腦 ( 包含計算機 ) 3. 不可以左顧右盼 不可以交談 不可以交換任何資料 試卷題目有任何疑問請舉手發問

More information

Microsoft Word finalSol.doc

Microsoft Word finalSol.doc 1051 NTOUCSE 程式設計 C 期末考參考答案 姓名 : 系級 : 學號 : 106/01/11( 三 ) 考試時間 :14:30 16:30 考試規則 :1. 請闔上課本, 不可參考任何文件包括小考 作業 實習 或是其他參考資料 2. 可以使用鉛筆, 可以在題目卷上直接回答, 但是請在答案卷上註明某題號的答案在題目卷上 3. 你覺得有需要的話, 可以使用沒有教過的語法, 但是僅限於 C 語言

More information

!249 第 八講 進階指標 講師 : 李根逸 (Ken-Yi Lee),

!249 第 八講 進階指標 講師 : 李根逸 (Ken-Yi Lee), 249 第 八講 進階指標 講師 : 李根逸 (Ken-Yi Lee), E-mail: feis.tw@gmail.com 250 課程 大綱 陣列的複製 [P.252] 字串的特殊性 [P.255] const 修飾字 [P.256] 指標陣列 [P.257] 字串陣列 [P.258] 指標與 二維陣列 [P.260] 動態記憶體配置與釋放 C 語 言中動態記憶體的配置 [P.266] C 語

More information

Microsoft PowerPoint - The Twelve Days of Xmas.ppt

Microsoft PowerPoint - The Twelve Days of Xmas.ppt The Twelve Days of Xmas https://www.youtube.com/v/kqeobzlx Z8 丁培毅 1 On the first day of Xmas A Partridge in a Pear Tree On the second day of Xmas On the third day of Xmas On the fourth day of Xmas Lyrics

More information

0 0 = 1 0 = 0 1 = = 1 1 = 0 0 = 1

0 0 = 1 0 = 0 1 = = 1 1 = 0 0 = 1 0 0 = 1 0 = 0 1 = 0 1 1 = 1 1 = 0 0 = 1 : = {0, 1} : 3 (,, ) = + (,, ) = + + (, ) = + (,,, ) = ( + )( + ) + ( + )( + ) + = + = = + + = + = ( + ) + = + ( + ) () = () ( + ) = + + = ( + )( + ) + = = + 0

More information

新・明解C言語入門編『索引』

新・明解C言語入門編『索引』 !... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177

More information

Microsoft PowerPoint - C-Ch11.ppt

Microsoft PowerPoint - C-Ch11.ppt 各式各樣的資料型態 11-1 結構的基礎知識 決定新的型態 關於結構 結構資料型態可以將不同資料型態的值整合成新的型態 結構型態的宣告語法 : struct 結構型態 { 資料型態識別字 ; 資料型態識別字 ; }; 加上 struct 進行宣告 宣告結構變數 語法 : 結構型態結構變數名稱 ; 範例 : struct Car car1; 對成員進行存取 使用結構型態的成員時, 必須使用成員選擇運算子

More information

Microsoft PowerPoint - 12 struct and other datatypes.ppt

Microsoft PowerPoint - 12 struct and other datatypes.ppt 第十一章結構與其它資料型態 結構與巢狀結構 結構陣列的各種使用方法 列舉型態 自定的型態別名 typedef 認識結構 使用者自定的資料型態 結構可將型態不同的資料合併成為新的型態 定義結構與宣告結構變數的格式如下 : struct 結構名稱 資料型態成員名稱 1; 資料型態成員名稱 2;... 資料型態成員名稱 n; struct 結構名稱變數 1, 變數 2,, 變數 n; 定義結構與宣告結構變數的語法

More information

untitled

untitled 1 DBF (READDBF.C)... 1 2 (filetest.c)...2 3 (mousetes.c)...3 4 (painttes.c)...5 5 (dirtest.c)...9 6 (list.c)...9 1 dbf (readdbf.c) /* dbf */ #include int rf,k,reclen,addr,*p1; long brec,erec,i,j,recnum,*p2;

More information

C/C++ - 函数

C/C++ - 函数 C/C++ Table of contents 1. 2. 3. & 4. 5. 1 2 3 # include # define SIZE 50 int main ( void ) { float list [ SIZE ]; readlist (list, SIZE ); sort (list, SIZE ); average (list, SIZE ); bargragh

More information

C 語言—陣列及字串

C 語言—陣列及字串 10/16 系程主講人 : 荊輔翔 概論 陣列 陣列是一個具有索引 (index) 性質的連續資料儲存空間集合 陣列中每一個資料儲存空間稱之為陣列元素 (array element); 它們都具有相同的資料名稱 資料型態 及空間大小 ; 但存取它們時則須藉由索引 ( 或稱註標 ) 來區別辨識 索引代表資料在陣列中的相對位址 ( 其計數由 0 開始, 其餘累加類推 ), 且須由中括號 [ ] 涵蓋之

More information

Microsoft PowerPoint - STU_C_Lang_CH13.ppt

Microsoft PowerPoint - STU_C_Lang_CH13.ppt 第 13 章 動態配置記憶體 程式設計與生活 - 使用 C 語言 Shi-Huang Chen Spring 2013 第 13 章 動態配置記憶體 13-1 記憶體配置函式 malloc( ) 13-2 動態配置結構陣列 配置記憶體 預估需求數量的範圍是一項不容易的學問 例 : 大到預估今年國家預算, 小到預估櫥窗裡展示的毛線衣, 需要多少磅毛線才能織成 撰寫程式時, 一樣無法預估程式執行所需的記憶體空間

More information

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf ("%d", & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf (%d, & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9 201 201 21 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 1 B 1 C 5 D RPG 10 E 10 F 1 G II 1 1 201 201 C 1 # include 2 int main ( void

More information

C

C C 2017 3 14 1. 2. 3. 4. 2/95 C 1. 3/95 C I 1 // talkback.c: 2 #include 3 #include 4 #define DENSITY 62.4 5 int main(void) 6 { 7 float weight, volume; 8 int size; 9 unsigned long letters;

More information

Microsoft Word - C-pgm-ws2010.doc

Microsoft Word - C-pgm-ws2010.doc Information and Communication Technology 資訊與通訊科技 Loops (while/for) C 廻路 姓名 : 班別 : ( ) CS C Programming #1 Functions 函數 : 1 若 n=14, 求以下表示式的值 Expressions 表示式 Value 值 Expressions 表示式 Value 值 A 20 2 * (n /

More information

c_cpp

c_cpp C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i

More information

氣泡排序 #include <stdio.h> int main() { int arr[] = { 22, 34, 3, 32, 82, 55, 89, 50, 37, 5, 64, 35, 9, 70 }; int len = (int) sizeof(arr) / sizeof(*arr);

氣泡排序 #include <stdio.h> int main() { int arr[] = { 22, 34, 3, 32, 82, 55, 89, 50, 37, 5, 64, 35, 9, 70 }; int len = (int) sizeof(arr) / sizeof(*arr); 氣泡排序 #include int main() int arr[] = 22, 34, 3, 32, 82, 55, 89, 50, 37, 5, 64, 35, 9, 70 ; int len = (int) sizeof(arr) / sizeof(*arr); int i, j, temp; for (i = 0; i < len - 1; i++) for (j = 0;

More information

<4D F736F F D DA5BFA6A1C476C1C92DBEC7ACECB8D5A8F728B57BB35D292E646F63>

<4D F736F F D DA5BFA6A1C476C1C92DBEC7ACECB8D5A8F728B57BB35D292E646F63> 全國高級中等學校 106 學年度商業類科學生技藝競賽 程式設計 職種 學科 試卷 選手證號碼 ( 崗位編號 ): 姓名 : 注意事項 : 請將答案劃記於答案卡, 未依規定劃記者不予計分 試題說明 :( 選擇題共 25 題每題 4 分, 答錯不倒扣, 共 100 分 ) ( )1. 執行以下 Visual Basic 程式片段, 其結果為何?(A) 15 (B) 12 (C) 7 (D) 3 Dim

More information

新版 明解C言語入門編

新版 明解C言語入門編 328, 4, 110, 189, 103, 11... 318. 274 6 ; 10 ; 5? 48 & & 228! 61!= 42 ^= 66 _ 82 /= 66 /* 3 / 19 ~ 164 OR 53 OR 164 = 66 ( ) 115 ( ) 31 ^ OR 164 [] 89, 241 [] 324 + + 4, 19, 241 + + 22 ++ 67 ++ 73 += 66

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

Microsoft Word cppFinalSolution.doc

Microsoft Word cppFinalSolution.doc 姓名 : 系級 : 學號 : 國立台灣海洋大學資訊工程系 C++ 程式設計期末考參考答案 101/06/19 考試時間 :09:30 12:00 請看清楚題目問什麼, 針對重點回答, 總分有 115, 請看清楚每一題所佔的分數考試規則 :1. 不可以翻閱參考書 作業及程式 2. 不得使用任何形式的電腦 ( 包含計算機 ) 3. 不得左顧右盼 不得交談 不得交換任何資料 試卷題目有任何疑問請舉手發問

More information

untitled

untitled 3 C++ 3.1 3.2 3.3 3.4 new delete 3.5 this 3.6 3.7 3.1 3.1 class struct union struct union C class C++ C++ 3.1 3.1 #include struct STRING { typedef char *CHARPTR; // CHARPTR s; // int strlen(

More information

C C

C C C C 2017 3 8 1. 2. 3. 4. char 5. 2/101 C 1. 3/101 C C = 5 (F 32). 9 F C 4/101 C 1 // fal2cel.c: Convert Fah temperature to Cel temperature 2 #include 3 int main(void) 4 { 5 float fah, cel; 6 printf("please

More information

C/C++程序设计 - 字符串与格式化输入/输出

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 177 [P179] (1) - [P181] [P182] (2) - for [P183] (3) - switch [P184] [P187] [P189] [P194] 178 [ ]; : : int var; : int var[3]; var 2293620 var[0] var[1] 2293620

More information

資料結構之C語言重點複習

資料結構之C語言重點複習 鏈結串列自編教材 ( 一 ) 本教材 ( 一 ) 目標問題 : 每次以亂數產生一 [0,1000] 之整數值, 若該值 >100, 則以同方式繼續產生下一亂數值, 若該值

More information

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

第1章

第1章 第 8 章 函式 1 本章提要 8.1 前言 8.2 如何定義函式 8.3 函式的呼叫和返回 8.4 傳遞陣列 8.5 方法多載 8.6 遞迴 8.7 綜合練習 8.8 後記 2 8.1 前言 每一種高階程式語言都有提供函式 (Function)( 或稱函數 ) 的功能, 以便將經常使用到的程式功能包裝成函式的形式, 如此一來便能反覆地呼叫該函式來完成某件特定工作在高階程式語言中, 副程式 (Subroutine)

More information

untitled

untitled 不 料 料 例 : ( 料 ) 串 度 8 年 數 串 度 4 串 度 數 數 9- ( ) 利 數 struct { ; ; 數 struct 數 ; 9-2 數 利 數 C struct 數 ; C++ 數 ; struct 省略 9-3 例 ( 料 例 ) struct people{ char name[]; int age; char address[4]; char phone[]; int

More information

untitled

untitled Introduction to Programming ( 數 ) Lecture 3 Spring 2005 March 4, 2005 Lecture 2 Outline 數 料 If if 狀 if 2 (Standard Output, stdout): 料. ((Standard Input, stdin): 料. 類 數 數 數 說 printf 見 數 puts 串 數 putchar

More information

Microsoft PowerPoint - Fig03_Stack.ppt [相容模式]

Microsoft PowerPoint - Fig03_Stack.ppt [相容模式] 四 堆疊與佇列 (Stack & Queue) 4-. 串列及鏈結串列 4-. 用陣列結構實作堆疊 4-3. 用鏈結串列實作堆疊 4-4. 堆疊的應用 4-5. 佇列 4-6. 用陣列結構實作佇列 4-7 7. 用鏈結串列實作佇列 堆疊的基本觀念. 定義 : 4- 堆疊 當將東西疊成一堆, 而取用的時候由上方來取出. 特性 : 先進後出, 後進先出 ( 號球先放, 但 3 號球會先拿出 ) 3 3

More information

新・解きながら学ぶC言語

新・解きながら学ぶC言語 330!... 67!=... 42 "... 215 " "... 6, 77, 222 #define... 114, 194 #include... 145 %... 21 %... 21 %%... 21 %f... 26 %ld... 162 %lf... 26 %lu... 162 %o... 180 %p... 248 %s... 223, 224 %u... 162 %x... 180

More information

1

1 基本練習題 1 答 :(A) 2 答 :(B) 3 答 :(C) 4 答 :(B) 5 答 :(D) 6 答 :2 7 答 :(B) 8 答 : (A) A B C / D E * + F G / - (B) A B + C D - * E / (C) A B C * + E F + - 9 答 : (A) - + A * - / BCDE / F G (B) / * + A B C D E (C)

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc 2 5 8 11 0 1. 13 2. 15 3. 18 1 1. 22 2. 25 3. 27 2 1. 35 2. 38 3. 41 4. 43 5. 48 6. 50 3 1. 56 2. 59 3. 63 4. 65 5. 69 13 22 35 56 6. 74 7. 82 8. 84 9. 87 10. 97 11. 102 12. 107 13. 111 4 114 1. 114 2.

More information

第3章.doc

第3章.doc 3 3 3 3.1 3 IT Trend C++ Java SAP Advantech ERPCRM C++ C++ Synopsys C++ NEC C C++PHP C++Java C++Java VIA C++ 3COM C++ SPSS C++ Sybase C++LinuxUNIX Motorola C++ IBM C++Java Oracle Java HP C++ C++ Yahoo

More information

CHAPTER VC#

CHAPTER VC# 1. 2. 3. 4. CHAPTER 2-1 2-2 2-3 2-4 VC# 2-5 2-6 2-7 2-8 Visual C# 2008 2-1 Visual C# 0~100 (-32768~+32767) 2 4 VC# (Overflow) 2-1 2-2 2-1 2-1.1 2-1 1 10 10!(1 10) 2-3 Visual C# 2008 10! 32767 short( )

More information

epub 33-8

epub 33-8 8 1) 2) 3) A S C I I 4 C I / O I / 8.1 8.1.1 1. ANSI C F I L E s t d i o. h typedef struct i n t _ f d ; i n t _ c l e f t ; i n t _ m o d e ; c h a r *_ n e x t ; char *_buff; /* /* /* /* /* 1 5 4 C FILE

More information

untitled

untitled 1 1.1 1.2 1.3 1.4 1.5 ++ 1.6 ++ 2 BNF 3 4 5 6 7 8 1.2 9 1.2 IF ELSE 10 1.2 11 1.2 12 1.3 Ada, Modula-2 Simula Smalltalk-80 C++, Objected Pascal(Delphi), Java, C#, VB.NET C++: C OOPL Java: C++ OOPL C# C++

More information

C/C++ - 结构体、共用体、枚举体

C/C++ - 结构体、共用体、枚举体 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 C C (struct) C 2 C C (struct) C 2 i // book.c: # include < stdio.h> # define MAX_ TITLE 41 # define MAX_ AUTHOR 31 struct book { char title [ MAX_ TITLE

More information

C/C++基礎程式設計班

C/C++基礎程式設計班 C/C++ 基礎程式設計 字元與字串 講師 : 張傑帆 CSIE, NTU 人的出身並不重要, 你拿時間來做什麼才重要 It s not who you were at birth that matters, but what you do with the time you are given.-steve Jobs 課程大綱 字元 字串 作業 字元 在電腦的世界裡, 所有的一切都是以 0 與 1

More information

Microsoft Word - CS-981.doc

Microsoft Word - CS-981.doc 4. 資料表示法 4.1 十進位與數字系統 (1). 基本觀念 數字系統的觀念 人們習慣以十進位的計量方式來計算 不同的數字系統有二進位 (Binary) 八進位 (Octal) 十進位 (Decimal) 十六進位(Hexadecimal) 二進位 電腦內部用來表達訊號的資料只有兩種符號 : 0 表示沒電,1 表示有電透過多個電路的組合表示出無數符號, 電腦便利用這些符號來表示不同的數字 利用兩條電線可以表示出

More information

本章內容 2-1 陣列及陣列位址的計算一維陣列位址計算多維陣列位址計算 2-2 一維陣列的基本運算讀取 寫入 複製 輸出 插入資料 刪除 2-3 二維陣列及矩陣的儲存與運算矩陣輸出 矩陣轉置 矩陣相加 矩陣相乘 2-4 字串 ( 字元陣列 ) 計算字串長度 字串複製 字串比較 子字串擷取 2

本章內容 2-1 陣列及陣列位址的計算一維陣列位址計算多維陣列位址計算 2-2 一維陣列的基本運算讀取 寫入 複製 輸出 插入資料 刪除 2-3 二維陣列及矩陣的儲存與運算矩陣輸出 矩陣轉置 矩陣相加 矩陣相乘 2-4 字串 ( 字元陣列 ) 計算字串長度 字串複製 字串比較 子字串擷取 2 第二章 Array 版權屬作者所有, 非經作者同意不得用於教學以外用途 1 本章內容 2-1 陣列及陣列位址的計算一維陣列位址計算多維陣列位址計算 2-2 一維陣列的基本運算讀取 寫入 複製 輸出 插入資料 刪除 2-3 二維陣列及矩陣的儲存與運算矩陣輸出 矩陣轉置 矩陣相加 矩陣相乘 2-4 字串 ( 字元陣列 ) 計算字串長度 字串複製 字串比較 子字串擷取 2 2-1 陣列及陣列位址的計算 陣列

More information

C/C++基礎程式設計班

C/C++基礎程式設計班 C/C++ 基礎程式設計 字元與字串 講師 : 張傑帆 CSIE, NTU 人的出身並不重要, 你拿時間來做什麼才重要 It s not who you were at birth that matters, but what you do with the time you are given.-steve Jobs 課程大綱 字元 字串 作業 字元 在電腦的世界裡, 所有的一切都是以 0 與 1

More information

日本清酒精妙绝伦的另一面

日本清酒精妙绝伦的另一面 日 本 清 酒 精 妙 绝 伦 的 另 一 面 过 度 认 真 执 著 的 日 本 人, 对 于 各 种 传 统 产 业 总 是 有 着 多 如 牛 毛 的 规 矩 和 禁 忌, 因 此 想 要 采 访 酒 庄 是 相 当 不 容 易 的 一 件 事 幸 运 的 是, 由 于 某 种 特 殊 的 机 缘, 笔 者 得 以 近 距 离 的 全 程 参 与 杜 氏 ( 首 席 酿 酒 师 ) 的 酿 酒

More information

Microsoft PowerPoint - scanfCommonTraps.ppt

Microsoft PowerPoint - scanfCommonTraps.ppt scanf 的緩衝區問題 與 scanf 支援的資料剖析功能 丁培毅 1 01 #include 02 #include 03 04 int main() { 05 char str[100]; 06 char symbol='\0'; 07 問題 1 描述 08 printf("please input a string: "); 09 scanf("%s",str);

More information

ESP-Jumpstart

ESP-Jumpstart 2016-2019 2019 08 08 Contents 1 3 1.1 ESP32.............................. 3 1.2.................................................. 5 2 7 2.1............................................. 7 2.2 ESP-IDF............................................

More information

extend

extend (object oriented) Encapsulation Inheritance Polymorphism Dynamic Binding (base class) (derived class) 1 class Base { int I; void X(); void Y(); class Derived: public Base { private: int j; void z(); Derived

More information

附 件 : 湖 北 省 会 计 人 员 继 续 教 育 实 施 办 法 第 一 条 为 规 范 会 计 人 员 继 续 教 育 工 作, 加 强 持 有 会 计 从 业 资 格 证 书 人 员 ( 以 下 简 称 会 计 人 员 ) 继 续 教 育 的 管 理, 推 进 全 省 会 计 人 员 继 续 教 育 工 作 科 学 化 规 范 化 信 息 化, 培 养 造 就 高 素 质 的 会 计 队

More information

2016 28 2016 2013 50 2013 69 2016 2016 10 2016 1 2016 24 2016 1 2016 2016 7 1 2017 6 30 1 2016 2 2012 17 2016 2016 24 2016 1 2016 1 2016 1 2016 1 2016 2016 24 2016 24 2016 24 24 12 2016 CN 24 24 12 2016

More information

Microsoft PowerPoint - EmbSys101_Java Basics.ppt [相容模式]

Microsoft PowerPoint - EmbSys101_Java Basics.ppt [相容模式] Java Basics Hi Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan chanhl@maili.cgu.edu.twcgu 執行環境 - eclipse 點選 eclipse 軟體執行檔 設定工作路徑 eclipse 開啟 2 建置 Java 專案 File New project

More information

C

C C 14 2017 5 31 1. 2. 3. 4. 5. 2/101 C 1. ( ) 4/101 C C ASCII ASCII ASCII 5/101 C 10000 00100111 00010000 ASCII 10000 31H 30H 30H 30H 30H 1 0 0 0 0 0 ASCII 6/101 C 7/101 C ( ) ( ) 8/101 C UNIX ANSI C 9/101

More information

一、

一、 考試時間 : 1 小時 30 分座號 : 全五頁第一頁 注意 : 禁止使用電子計算器 不必抄題, 作答時請將試題題號及答案依照順序寫在試卷上, 於本試題上作答者, 不予計分 一 就下列 Java 程式片斷中加入一個 for 迴圈, 使其印出右側結果 (15 分 ) public class AllNumbers number square cube 0 0 0 public static void

More information

第1章

第1章 第 7 章 字串 1 本章提要 7.1 前言 7.2 類別與物件 7.3 String 類別 7.4 StringBuffer 類別 7.5 綜合練習 7.6 後記 2 7.1 前言 Java 用 String 類別 (Class) 來處理字串, String 類別是 Java 類別庫內建的類別, 它是一堆已經寫好的程式, 我們可以直接拿來使用字串很像字元型別的一維陣列, 字串裡能存放的資料都屬於字元性質,

More information

運算子多載 Operator Overloading

運算子多載 Operator Overloading 函數樣板 (Function Template) 與 類別樣板 (Class Template) 講師 : 洪安 1 資料結構與 C++ 程式設計進階班 為何需要通用函數? (1/2) int abs(int x) { return (x>0)?x:-x; 取名困難不好記 float fabs(float x) { return (x>0)?x:-x; complex cabs(complex x)

More information

Microsoft Word - Prog1-981.docx

Microsoft Word - Prog1-981.docx 5. 變數參照 (Memory Reference) 5.1 指標 (Pointer) (1). 指標 (Pointer) 的基本觀念 特性 內含為一 Memory Address 會因不同的機器而有不同的結果 &" 也是代表變數的位址 例如 : int var1 = 2; cout

More information

untitled

untitled 串 串 例 : char ch= a ; char str[]= Hello ; 串 列 ch=getchar(); scanf( %c,&ch); 串 gets(str) scanf( %s,str); 8-1 數 ASCII 例 : char ch= A ; printf( %d,ch); // 65 A ascii =0x41 printf( %c,ch); // A 例 : char ch;

More information

The golden pins of the PCI card can be oxidized after months or years

The golden pins of the PCI card can be oxidized after months or years Q. 如何在 LabWindows/CVI 編譯 DAQ Card 程式? A: 請參考至下列步驟 : 步驟 1: 安裝驅動程式 1. 安裝 UniDAQ 驅動程式 UniDAQ 驅動程式下載位置 : CD:\NAPDOS\PCI\UniDAQ\DLL\Driver\ ftp://ftp.icpdas.com/pub/cd/iocard/pci/napdos/pci/unidaq/dll/driver/

More information

第一章

第一章 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1500 1450 1400 1350 1300 1250 1200 15 16 17 18 19 20 21 22 23 24 25 26 27 28 INPUT2006 29 30 31 32 33 34 35 9000 8500 8000 7500 7000 6500 6000 5500 5000 4500 4000 3500

More information

C/C++语言 - C/C++数据

C/C++语言 - C/C++数据 C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;

More information

p-2

p-2 B 卷 選擇題 共 50 題 ( 共 100 分 ) 1. 執行下列 Visual Basic 程式片段後, 共輸出幾筆資 料? x = 0: y = 1 Print y x = x + y Print x y = y + 1 If x >= 10 Then Exit Loop While y

More information

文档 1

文档 1 2005 3 100 2005 10 20 100 100 2003 9 30 266,303,262.93 100 941,105,695.50 532,672,384.52 1 2 100 100 100 90% 100 50% 100 100 2005 8 21 "75% 100 + 25% " 2005 8 22 100 95%+ 5% 3 75% + 25% 2005 7 1 2005 9

More information

Microsoft PowerPoint - STU_C_Lang_CH06.ppt

Microsoft PowerPoint - STU_C_Lang_CH06.ppt 第 6 章庫存函式 程式設計與生活 - 使用 C 語言 Shi-Huang Chen Spring 2013 1 第 6 章 庫存函式 6-1 常用庫存函式 6-2 數學運算函式 6-3 字元轉換及字元分類函式 6-4 時間與日期函式 6-5 聲音函式 6-6 停滯函式 2 函式 凡是具有特定功能的程式稱之為函式 (function) 當某種特定的功能需要常常被使用時, 我們必須將此特定功能撰寫成一函式,

More information

ActiveX Control

ActiveX Control ActiveX Control For Visual Basic 2005.NET [ 版本 : 1.0] 1 安裝 Windows 驅動程式 請依照下列步驟 : 1. 執行 Windows 驅動程式安裝程式 ( 此範例為 PIO-DIO) 驅動程式位置 : CD:\NAPDOS\PCI\PIO-DIO\dll_ocx\Driver http://ftp.icpdas.com/pub/cd/iocard/pci/napdos/pci/pio-dio/dll_ocx/driver/

More information

ebook39-5

ebook39-5 5 3 last-in-first-out, LIFO 3-1 L i n e a r L i s t 3-8 C h a i n 3 3. 8. 3 C + + 5.1 [ ] s t a c k t o p b o t t o m 5-1a 5-1a E D 5-1b 5-1b E E 5-1a 5-1b 5-1c E t o p D t o p D C C B B B t o p A b o

More information

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit 6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C51 6.1 C51 6.1.1 C51 C51 ANSI C MCS-51 C51 ANSI C C51 6.1 6.1 C51 bit Byte bit sbit 1 0 1 unsigned char 8 1 0 255 Signed char 8 11 128

More information

Microsoft Word - DataStruct-981.doc

Microsoft Word - DataStruct-981.doc 4. 堆疊與佇列 (Stack and Queue) 4. Stak (). 基本觀念 定義 : 當將東西疊成一堆, 而取用的時候由上方來取出 特性 : 先進後出, 後進先出 ( 號球先放, 但 3 號球會先拿出 ) 2 3 3 2 (2). Stack 的運算 基本運算 push: 將資料放入堆疊 pop: 將資料由堆疊最頂端取出一個 TopItem: 位於堆疊中最上面的一個資料 IsEmpty:

More information

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023) ( CIP) /. :, 2005. 2 ( ) ISBN 7-5624-3339-9.......... TP311. 1 CIP ( 2005) 011794 : : : : * : : 174 ( A ) :400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / /www. cqup. com. cn : fxk@cqup.

More information

nooog

nooog C : : : , C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, 6 10 11, 7 8, 12 13,,,,, 2008 1 1 (1 ) 1.1 (1 ) 1.1.1 ( ) 1.1.2 ( ) 1.1.3 ( ) 1.1.4 ( ) 1.1.5 ( ) 1.2 ( ) 1.2.1

More information

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer trio@seu.edu.cn 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

More information

Microsoft PowerPoint - 13_指標、資料傳遞2.pptx

Microsoft PowerPoint - 13_指標、資料傳遞2.pptx 1 2 指標 Lecture 13 指標函式呼叫的資料傳遞 (III) 傳址指標與陣列 Pointer 3 4 指標 / 指位器 (Pointer) 變數 int a; 整數型別, 名稱為 a 變數是為了使用記憶體資源來儲存資料與進行運算 所有的變數都佔有記憶體空間 記憶體 可視為一個很大的一維陣列, 單位是 byte 問題 一個 4KB 的電腦, 其記憶體位置 ( 編號 ) 從 0 至? 4 x

More information

Microsoft PowerPoint - java2012-ch12投影片.ppt

Microsoft PowerPoint - java2012-ch12投影片.ppt 第十二章大型程式的發展與常用的類別庫 學習如何分割檔案認識類別庫以及取用類別庫裡的類別建構 package 的階層關係學習 Java 裡常用的類別庫 1 分割檔案的實作 (1/2) 12.1 檔案的分割 以 CCircle 類別為例, 說明分割檔案的實作 1. 依序建立兩個類別檔案, 並置於同一個資料夾內 : 2 分割檔案的實作 (2/2) 12.1 檔案的分割 2. 分別以下列的指令編譯 CCircle.java

More information

C/C++ - 字符输入输出和字符确认

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

<4D F736F F D B0D3B77EC3FEA7DEC3C0C476C1C9A5BFA6A1B8D5C3442DB57BA6A1B35DAD702DBEC7ACEC2E646F6378>

<4D F736F F D B0D3B77EC3FEA7DEC3C0C476C1C9A5BFA6A1B8D5C3442DB57BA6A1B35DAD702DBEC7ACEC2E646F6378> 全國國高級中中等學校 105 學年度商商業類學學生技藝藝競賽 程式式設計 職職種 學學科 試試卷 崗位位編號 : 姓名 : 注意事項 : 請將答案案劃記於答案案卡, 未依依規定劃記者者不予計分分 試題說明 :( 選擇題每每題 4 分, 共 100 分 ) ( )1. 執行以下 Visual Basic 程式片段, 其結果為何?(A) 15 Dim i As Byte i = &HFC Console.WriteLine(Not

More information

Microsoft Word - About_C_PointerAdvanced.doc

Microsoft Word - About_C_PointerAdvanced.doc (*) 如何宣告或解讀某一個資料型態的指標變數? 在變數名稱前加上一個 * 號 ( 陣列也可算成是指標只是其值不能被更改!) 反過來在解讀變數的型態時 : 先找到變數名稱, 再看其左邊是否有星號 ( 至多取一個 ), 若有表示這是一個指標變數, 否則就是一般的變數 至於資料型態的部份, 只要將變數或連同 * 號移去後, 剩下的部份就是此變數或指標的資料型態 (*) 優先順序 : 運算子的優先順序 5

More information

3. 給 定 一 整 數 陣 列 a[0] a[1] a[99] 且 a[k]=3k+1, 以 value=100 呼 叫 以 下 兩 函 式, 假 設 函 式 f1 及 f2 之 while 迴 圈 主 體 分 別 執 行 n1 與 n2 次 (i.e, 計 算 if 敘 述 執 行 次 數, 不

3. 給 定 一 整 數 陣 列 a[0] a[1] a[99] 且 a[k]=3k+1, 以 value=100 呼 叫 以 下 兩 函 式, 假 設 函 式 f1 及 f2 之 while 迴 圈 主 體 分 別 執 行 n1 與 n2 次 (i.e, 計 算 if 敘 述 執 行 次 數, 不 1. 右 側 程 式 正 確 的 輸 出 應 該 如 下 : * *** ***** ******* ********* 在 不 修 改 右 側 程 式 之 第 4 行 及 第 7 行 程 式 碼 的 前 提 下, 最 少 需 修 改 幾 行 程 式 碼 以 得 到 正 確 輸 出? (A) 1 (B) 2 (C) 3 (D) 4 1 int k = 4; 2 int m = 1; 3 for (int

More information

Microsoft Word - Index.doc

Microsoft Word - Index.doc Programmer: B95902048 B95902085 WaveData #include ham // gfx2gba -fsrc -m -pb.pal -t8 water.bmp bg1.bmp bg2.bmp gameover.bmp water_atked.bmp #include "gfx/bg.pal.c" #include "gfx/bg.raw.c"

More information