Microsoft Word - About_C_DynamicMemoryAllocation.doc

Size: px
Start display at page:

Download "Microsoft Word - About_C_DynamicMemoryAllocation.doc"

Transcription

1 (*) 動態記憶體配置為什麼需要使用動態記憶體配置? 更有效率的使用記憶體, 這包括可以在需要時才根據需求來配置適量的記憶體, 而不必一開始就宣告可容納最大可能大小的陣列 ; 另一個重要的情況則是可以突破堆疊 (stack) 的大小限制, 在堆積 (heap) 上宣告目前可用記憶體容許的最大空間 在 C 中, 實現動態記憶體配置的方法 : DataType *ptr = (DataType*) malloc( 所需的記憶空間的 bytes 數 ); 其中 malloc(.) 如果成功會傳回型態是 void* 的位址 ; 若失敗則傳回 NULL 上述宣告中的 ptr 當配置成功時, 就會指向系統所給予這塊記憶體的起始位址 精確地說, 這塊連續的記憶體空間可以用任意的資料型態來進行存取, 不過此刻為避免模糊了焦點, 所以就單純地以原來設定的方式來使用它 例如 : 要配置 2000 個整數 (int) 型態的記憶體空間可以使用下列的程式碼 : int *data = (int*) malloc( sizeof(int)*2000); 這時我們發現到 sizeof(.) 重要性在此突顯出來了! 另外, 一個好的習慣希望大家在配置記憶體時能夠養成 : 宣告後要做配置成功與否的檢查! if ( ptr==null ) // 當失敗時該做的收尾工作! ; 此外, 有件大家必須牢記也是在學習 C 語言記憶體配置時最容易犯錯的事情 : 忘記釋放之前配置的記憶體, 造成記憶體漏失的問題! 這些向系統請求的記憶體空間, 必須要由程式設計者自己釋放它們 記憶體漏失問題有時就發生在 : 1) 或許過早釋放這些記憶體導致稍後讀不到它們 ; 2) 或者是使用後竟忘了釋放它們 對系統而言, 這些記憶體原則上被為視為使用者專屬, 系統不再具有控制權, 因此釋放的動作要由程式寫作者來決定與實作 一旦因記憶體漏失而破壞記憶體的連續性時, 可能使得稍後要使用的記憶體空間遭到截斷, 以致於接下來系統能再配置的記憶空間大小受到很大的影響, 甚或更嚴重時的發生配置失敗的狀況 以實例說明動態記憶體配置與釋放的過程 : int *data = (int*) malloc( sizeof(int)*2000); if ( data==null ) // 配置失敗時要進行的處置! ; // 對配置的記憶體進行需要的操作! : free(data); // 釋放已配置的記憶體 In C++, int *data = new int[2000]; if ( data==null ) // 配置失敗時要進行的處置! ; // 對配置的記憶體進行需要的操作! : delete [] data;

2 (*)C/C++ 隨機數值 (random number) 的產生與應用 1) 提供的函式 (function): int rand(void): 傳回介於 0 到 RAND_MAX(0x7FFF) 的正整數 void srand(unsigned seed): 指定的種子值即起始狀態 2) 使用 rand(), srand(.) 時, 需引用的 Header File: #include <stdlib.h> Part of file stdlib.h is listed below,... /* * RAND_MAX is the maximum value that may be returned by rand. * The minimum is zero. */ 4) 一個利用 rand() 產生十個隨機數的例子 : #include <stdlib.h> #include <stdio.h> int main(void) printf("ten random numbers from 0 to 99\n\n"); for (int i=0; i<10; i++) printf("%d\n", rand() % 100); system( pause ); return 0; // 每次執行的結果是否相同? #include <stdlib.h> #include <stdio.h> int main(void) srand(1); // 重新設定隨機數的產生順序 printf("ten random numbers from 0 to 99\n\n"); for (int i=0; i<10; i++) printf("%d\n", rand() % 100); system( pause ); return 0; // srand(1) 參數的值會影響每次執行的結果嗎? 5) 一個讓每次執行均能產生不同隨機數的函式 :randomize() #include <stdlib.h> #include <stdio.h> #include <time.h> // for time_t // 利用擷取現在時間, 作為任意指定的 seed 值, 如此則每次執行所產生的 // 隨機數就會不一樣 void randomize() int i; time_t t; srand((unsigned) time(&t)); int main(void) randomize(); printf("ten random numbers from 0 to 99\n\n"); for (int i=0; i<10; i++) printf("%d\n", rand() % 100); system( pause ); return 0;

3 6) 產生任意範圍的隨機數 : 要產生 0 ~ 99 的隨機數 :rand() % 100 要產生 0 ~ N-1 的隨機數 :rand() % N 要產生 a ~ b 的隨機數 :a + (rand() % (b-a+1)) 所以要產生 1 ~ 6 的隨機數 :( 可以用來模擬骰子的投擲點數 ) 1 + (rand() % (6-1+1)) => 1 + (rand() % 6) #include <stdlib.h> #include <stdio.h> #include <time.h> // for time_t void randomize() int i; time_t t; srand((unsigned) time(&t)); int random(int N) // return the value between 0 ~ N-1 return ( rand() % N ); int main(void) int k, number[6], index, total=1000; for (k=0; k<6; ++k) number[k]=0; // 設初始値 randomize(); for (k=0; k<total; ++k) index = random(6); // get the value between 0~5 number[index] = number[index] + 1; printf(" 模擬骰子投擲 %d 次的結果 \n\n", total); for (k=0; k<6; ++k) printf("[%d]:%4d\n", k+1, number[k]); system( pause ); return 0; 7) 試問如何產生小數點以下三位, 且值小於 1 的隨機小數? ( 提示 : 產生 0~999 的隨機整數, 再除以 1000 即可 ) (*) srand(int seed) 隨機數是透過一開始給定的種子值 seed, 接著進行後續的迭代計算來求出下一個隨機數 這也就是說儒果每次開始的狀態都一樣, 即種子值相同時那麼接續產生的隨機數列也會是一樣的! 這對於希望能儘可能每次出現不同莊況的應用而言, 應該是不樂見的結果 不過如果我們希望可以在稍後重現這個隨機數列, 如重印考試座位表或輪班表時, 固定的種子值能夠讓我們再次得到某一特定的隨機數列

4 例題 : 產生 10 個元素的 double 陣列, 將 1 到 10 的常用對數值存入其中並印出 #include <stdlib.h> // for malloc(.) and free(.) #include <math.h> // for log(.) void showdoubleten() int k, n = 10; // 動態配置記憶體, 用法同一般陣列 double *data = (double*) malloc( sizeof(double)*n ); // 檢查記憶體配置是否成功? if ( data==null ) return; for (k=0; k<n; ++k) data[k] = log(k+1) / log(10); printf("data[%d]= %.4f\n", k, data[k]); free( data ); // 勿忘! 釋放動態配置的記憶體! 例題 : 隨機產生 元素 int 陣列的值, 並找出與你學號末碼相同的項數共有幾個? #include <stdlib.h> // for malloc(.) and free(.) #include <math.h> // for log(.) #include <time.h> // for time_t void randomize() int i; time_t t; srand((unsigned) time(&t)); int random(int N) // return the value between 0 ~ N-1 return ( rand() % N ); void showyourno(int no) int k, found=0, n = 10000; // 動態配置記憶體, 用法同一般陣列 int *data = (int*) malloc( sizeof(int)*n ); // 檢查記憶體配置是否成功? if ( data==null ) return; randomize(); for (k=0; k<n; ++k) data[k] = random(100); if ( no==data[k] ) printf("data[%d]=%d\n", k, data[k]); ++found; printf(" 共找到 %d 項!\n", found); free( data ); // 勿忘! 釋放動態配置的記憶體!

5 (*) 可以宣告多大的陣列 ( 靜態與動態 )? #include <stdio.h> #include <stdlib.h> void bigarrayinfunction() // stack int ary1[ 10000]; // stored in stack //int ary2[100000]; //int ary3[200000]; //int ary4[400000]; //int ary6[600000]; void dynamicarrayinfunction() int * ary; ary = (int*) malloc(sizeof(int)*600000); // stored in heap system("pause"); free(ary); int main(int argc, char *argv[]) bigarrayinfunction(); dynamicarrayinfunction(); system("pause"); return 0; 透過動態記憶體配置的方式, 可以宣告不受堆疊大小限制的陣列, 實用上非常重要!

6 (*) 不公平的骰子 (an unfair die) 例題 : 模擬一不公平骰子, 希望某一點數出現的機率是其他點數的兩倍 void unfairdie() int k, value, n=700; int dice[6] = 0; // 將所有的陣列元素設成 0 //randomize(); // 產生任意的隨機數 //srand(1); // 產生特定順序的隨機數 for (k=0; k<n; ++k) value = random(7); // 產生介於 0~6 的隨機數 switch( value ) case 0: case 1: ++dice[0]; break; // 機率是其他的兩倍, 包括 0 與 1 case 2: ++dice[1]; break; case 3: ++dice[2]; break; case 4: ++dice[3]; break; case 5: ++dice[4]; break; case 6: ++dice[5]; break; ; printf(" 模擬不公平骰子擲 %d 次的結果 \n\n", n); for (k=0; k<6; ++k) printf("point %d:%4d\n", k+1, dice[k]);

7 (*) 動態產生二維陣列先動態產生所需的列, 再設定各列要對應或指向的動態配置記憶區塊 原則上 : 釋放記憶體的順序要與原先配置的順序反過來 DataType ** pptr; 指標的指標, 或者想成是指向某一陣列的指標 1) 具有相同 column 數的二維陣列 ( 矩形 ) (a) 動態產生各列所需的記憶體區塊 ( 產生 row 列, 再逐一設定 col 行 ) int** gen2darray(int row, int col) int r, c; int ** ary2d = (int**) malloc( (row)*sizeof(int*)); if ( ary2d==null ) return NULL; ary2d[r] = (int*) malloc( col*sizeof(int) ); if ( ary2d[r]==null ) // 一旦出錯所有稍早成功的配置均須釋放! for (c=r-1; c>=0; --c) free(ary2d[c]); return NULL; return ary2d; void release2darray(int** ary2d, int row) int r; free(ary2d[r]); void test2darray(int row, int col) int r, c; int** data = gen2darray(row, col); for (c=0; c<col; ++c) data[r][c] = r*10 + c; for (c=0; c<col; ++c) printf("data[%d][%d]=%2d ", r, c, data[r][c]); printf("\n"); release2darray(data, row);

8 (b) 先配置記憶區塊, 再將各列指標指向該區塊適當位址 ( 產生 row+1 列 ) int** gen2darray(int row, int col) int r, c; int ** ary2d = (int**) malloc( (row+1)* sizeof(int*)); if ( ary2d==null ) return NULL; ary2d[row] = (int*) malloc( row*col*sizeof(int) ); if ( ary2d[row]==null ) return NULL; ary2d[0] = ary2d[row]; for (r=1; r<row; ++r) ary2d[r] = ary2d[r-1] + col; // 指標的加減 return ary2d; void release2darray(int** ary2d, int row) free(ary2d[row]); void test2darray(int row, int col) int r, c; int** data = gen2darray(row, col); for (c=0; c<col; ++c) data[r][c] = r*10 + c; for (c=0; c<col; ++c) printf("data[%d][%d]=%2d ", r, c, data[r][c]); printf("\n"); 測試例 : test2darray(int row, int col); => test2darray(10, 5);

9 2) 可以有不同 column 數的二維陣列 ( 非矩形或鋸齒形 ) int** gen2darrayvar(int row, int col[]) // 此處的 col 是陣列! int r, c; int ** ary2d = (int**) malloc( (row)*sizeof(int*)); if ( ary2d==null ) return NULL; ary2d[r] = (int*) malloc( col[r]*sizeof(int) ); if ( ary2d[r]==null ) for (c=r-1; c>=0; --c) free(ary2d[c]); return NULL; return ary2d; void release2darrayvar(int** ary2d, int row) int r; free(ary2d[r]); void test2darrayvar(int row, int col[]) int r, c; int** data = gen2darrayvar(row, col); for (c=0; c<col[r]; ++c) data[r][c] = r*10 + c; for (c=0; c<col[r]; ++c) printf("data[%d][%d]=%2d ", r, c, data[r][c]); printf("\n"); 測試例 : int cols[] = 5,4,3,5,2; test2darrayvar(int row, int col[]); => test2darrayvar(5, cols);

10 (*) 一維陣列的記憶體配置與釋放 int *ptr=null; ptr = (int*) malloc( N*sizeof(int) ); if ( ptr==null ) return; free(ptr); (*) 二維陣列 (row, col) 的記憶體配置與釋放 - 方法 1 1) 記憶體的配置 : int ** ary2d = (int**) malloc( row *sizeof(int*)); ary2d[r] = (int*) malloc( col *sizeof(int) ); // 逐一配置 2) 記憶體的釋放 : free(ary2d[r]); (*) 二維陣列 (row, col) 的記憶體配置與釋放 - 方法 2 1) 記憶體的配置 : int ** ary2d = (int**) malloc( (row+1) *sizeof(int*)); // 先配置一塊連續的記憶體 : ary2d[row] = (int*) malloc( row*col *sizeof(int) ); // 將各個陣列指標指向各列正確的位址 : ary2d[0] = ary2d[row]; for (r=1; r<row; ++r) ary2d[r] = ary2d[r-1] + col; // 指標的加減 2) 記憶體的釋放 : free(ary2d[row]); (*) 在配置記憶體後, 要立即檢查是否正確配置 ; 使用後務必記得釋放該配置的記憶體

11 連續的記憶連續的記憶體連續的記憶體C 程式語言 - 動態記憶體配置介紹 (richwang) ptr Heap( 堆積 ) ptr2d ptr2d+1 ptr2d+2 ptr2d+row-1 體不L 1 L 2 尚未或忘了釋放的記憶體 此時雖有最大為 L 的空間, 也僅能一次選用 L 1 或 L 3 L L 3 ptr2d+row ptr2d ptr2d+1 ptr2d+2 記憶體配置的說明圖示

12 (*) 利用 typedef 簡化資料的表示 struct StudentS char no[11+1]; int chi; int eng; int math; ; // 分號 ; 不可或缺! 使用法 :(In C) struct StudentS stu, *pstu; // pstu 是指標 typedef struct char no[11+1]; int chi; int eng; int math; Student, *pstudent; // Student, pstudent 現在都是自訂的資料型態 使用法 : Student stu; pstudent pstu; // pstu 是指標 void genstudent(int N) // 有三種使用方式 : Student *stu = (Student*) malloc(sizeof(student) * N); //struct StudentS *stu = (Student*) malloc(sizeof(struct StudentS)*N); //pstudent stu = (pstudent) malloc(sizeof(student) * N); if ( stu==null ) printf("memory allocation failed!\n"); return; int k, c; randomize(); for (k=0; k<n; ++k) sprintf(stu[k].no, "S9917%03d", k+1 ); // 另一種寫法 stu[k].chi = random(101); stu[k].eng = random(101); stu[k].math = random(101); printf("%s: %d, %d, %d.\n", stu[k].no, stu[k].chi, stu[k].eng, stu[k].math); free(stu); // 有借要還! 一定要記得釋放記憶體! (*) sprintf( 儲存輸出的字串變數, 格式字串 [, 參數列 ]); sprintf(.) 的功能全同於 printf(.) 差別在 :printf 會將結果送往 stdout( 通常就是螢幕 ); 而 sprintf 會將相同的結果寫入字串變數中 不過要注意的是, 用來儲存輸出的字串的空間不可太小以免資訊無法正確存入, 導致訊息失真

13 (*) C 語言中對記憶體內容的操作 1) 設定記憶體資料的方法 : void *memset(void *s, int c, size_t n); fromaddr, tovalue, bytes 2) 搬移記憶體資料的方法 : void *memmove(void *dest, const void *src, size_t n); toaddr, fromaddr, bytes (destination: 目的地 ; source: 來源 ) // // #include <mem.h> // for using memset(.) and memmove(.) // 或直接使用 #include <string.h> 即可 void testmemfun() char buffer[] = "Hello world!\n"; // 最後有換行字元! printf("buffer before memset: %s\n", buffer); memset(buffer, '#', strlen(buffer) - 1); // strlen 求字串長度 printf("buffer after memset: %s\n", buffer); //========================================================== char dest[] = "abcdefghijklmnopqrstuvwxyz "; char src[] = "******************************"; printf("destination prior to memmove: %s\n", dest); memmove(dest, src, 26); // memmove(toaddr, fromaddr, bytes) printf("destination after memmove: %s\n", dest); //========================================================== (*) 以記憶體搬移的方式實作陣列的元素插入在資料 c 前插入資料 x: 陣列或記憶體中原來的資料 :data[k] a b c d e f (1) 先把資料搬到後面 (memmove) a b c c d e f memmove(&data[3], &data[2], sizeof(int)*4); or memmove(data+3, data+2, sizeof(int)*4); 或逐一搬移資料, for (k=4; k>0; --k) data[2+k] = data[2+k -1]; (2) 插入資料 x: a b x c d e f data[2] = x; 或者是在將一陣列中某個元素的內容移到最前面時, 也可以用相同的方式 這時需要更精確知道陣列的大小 與哪個元素需要被搬移到哪個位置等資訊, 請同學自己想想看! value = data[index]; // index 從 0 開始! memmove(&data[1], &data[0], index*sizeof(datatype)); data[0] = value;

新・明解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 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

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

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

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

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

新版 明解C++入門編

新版 明解C++入門編 511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,

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.doc

附錄C.doc C C C-1 C -2 C -3 C -4 C -5 / C -6 2 C/C++ C-1 FILE* fopen(const char* filename, const char* mode) filename NULL FILE* freopen(const

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

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

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 C 2017 4 1 1. 2. while 3. 4. 5. for 6. 2/161 C 7. 8. (do while) 9. 10. (nested loop) 11. 12. 3/161 C 1. I 1 // summing.c: 2 #include 3 int main(void) 4 { 5 long num; 6 long sum = 0L; 7 int status;

More information

C/C++ 语言 - 循环

C/C++ 语言 - 循环 C/C++ Table of contents 7. 1. 2. while 3. 4. 5. for 6. 8. (do while) 9. 10. (nested loop) 11. 12. 13. 1 // summing.c: # include int main ( void ) { long num ; long sum = 0L; int status ; printf

More information

Microsoft PowerPoint - 04-array_pointer.ppt

Microsoft PowerPoint - 04-array_pointer.ppt Array 與 Pointer Array Dynamical Memory Allocation Array( 陣列 ) 陣列是用來存放同樣型態的資料陣列的大小必須在程式中預先設定在程式執行中, 陣列的大小無法改變陣列中的資料是透過索引 (index) 來存取 一維陣列的宣告 type array_name[array_size]; int iarray[100]; /* an integer array

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

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

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

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

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

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

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

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

第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

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

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++基礎程式設計班

C/C++基礎程式設計班 C/C++ 基礎程式設計 指標 (Pointer) 講師 : 張傑帆 CSIE, NTU 瘋到自以為能改變世界的人, 就能改變世界 The people who are crazy enough to think they can change the world are the ones who do.-steve Jobs 課程大綱 指標簡介 陣列與指標 動態記憶體配置 指標宣告進階 指標 用途

More information

Microsoft Word - ¤W½Ò¤º®e RTF

Microsoft Word - ¤W½Ò¤º®e RTF (variable) &( ) ( ) 0 9 A...Z a z under line( _ ) 1) (A...Z a z) 2) case sensitive 3) C/C++ (reserved word or key word) 1, 2,.., n char ch; int m; int n; int m, n; // float f = 10.0; // double d =f * 10.0;

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

[改訂新版]C言語による標準アルゴリズム事典

[改訂新版]C言語による標準アルゴリズム事典 iii C 1991 SEND + MORE = MONEY C 100 2003 Java 2003 27 PC-9800 C BMP SVG EPS BMPSVG WindowsMacLinux Web iv int main() int main(void) EXIT_SUCCESS 0 https://github.com/okumuralab/ algo-c TEX TEX PDF PDF

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3 浙江大学 C 程序设计及实验 试题卷 2002-2003 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:30-10:30 注意 : 答题内容必须写在答题卷上, 写在本试题卷上无效 一. 单项选择题 ( 每题 1 分, 共 10 分 ) 1. 下列运算符中, 优先级最低的是 A.

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

BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2

BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2 PowerBuilder 9 PowerBuilder Native Interface(PBNI) PowerBuilder 9 PowerBuilder C++ Java PowerBuilder 9 PBNI PowerBuilder Java C++ PowerBuilder NVO / PowerBuilder C/C++ PowerBuilder 9.0 PowerBuilder Native

More information

Microsoft PowerPoint - C-Ch11.ppt

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

More information

Microsoft Word - About_C_PointerAdvanced.doc

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

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

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File 51 C 51 51 C C C C C C * 2003-3-30 pnzwzw@163.com C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

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

( 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

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

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

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

untitled

untitled 1 5 IBM Intel 1. IBM 第 1/175 页 第 2/175 页 第 3/175 页 80 第 4/175 页 2. IBM 第 5/175 页 3. (1) 第 6/175 页 第 7/175 页 第 8/175 页 = = 第 9/175 页 = = = = = 第 10/175 页 = = = = = = = = 3. (2) 第 11/175 页 第 12/175 页 第 13/175

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

1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7

1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7 1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7-80097 - 564-9 /TP 8 : 10. 00 ,,,, 1994 NCRE,,, ( ),,,,,

More information

C语言的应用.PDF

C语言的应用.PDF AVR C 9 1 AVR C IAR C, *.HEX, C,,! C, > 9.1 AVR C MCU,, AVR?! IAR AVR / IAR 32 ALU 1KBytes - 8MBytes (SPM ) 16 MBytes C C *var1, *var2; *var1++ = *--var2; AVR C 9 2 LD R16,-X ST Z+,R16 Auto (local

More information

Searching and Sorting

Searching and Sorting Introduction to Programming ( 數 ) Lecture 11 Spring 2005 May 27, 2004 NCCU C prog. 1 Topics Review More on Structures Unions Dynamic Memory Allocation Linked list, Queue NCCU C prog. 2 Structure in C (

More information

Ps22Pdf

Ps22Pdf C ( CIP) C /. :, 2001. 7 21 ISBN 7-5624 -2355-5. C........ C. TP312 CIP ( 2001 ) 034496 C * * : 7871092 1 /16 : 14. 25 : 356 20017 1 20017 1 : 1 6 000 ISBN 7-5624-2355-5 / TP311 : 21. 00 C, C,,,, C,, (

More information

How to Debug Tuxedo Server printf( Input data is: %s, inputstr); fprintf(stdout, Input data is %s, inputstr); fprintf(stderr, Input data is %s, inputstr); printf( Return data is: %s, outputstr); tpreturn(tpsuccess,

More information

static struct file_operations gpio_ctl_fops={ ioctl: gpio_ctl_ioctl, open : gpio_open, release: gpio_release, ; #defineled1_on() (GPBDAT &= ~0x1) #def

static struct file_operations gpio_ctl_fops={ ioctl: gpio_ctl_ioctl, open : gpio_open, release: gpio_release, ; #defineled1_on() (GPBDAT &= ~0x1) #def Kaise s 2410 Board setting [1]. Device Driver Device Driver Linux s Kernel ARM s kernel s3c2410_kernel2.4.18_r1.1_change.tar.bz2 /usr/src (1) #cd /usr/src (2) #tar xfj s3c2410_kernel2.4.18_r1.1_change.tar.bz2

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

全国计算机技术与软件专业技术资格(水平)考试

全国计算机技术与软件专业技术资格(水平)考试 全 国 计 算 机 技 术 与 软 件 专 业 技 术 资 格 ( 水 平 ) 考 试 2008 年 上 半 年 程 序 员 下 午 试 卷 ( 考 试 时 间 14:00~16:30 共 150 分 钟 ) 试 题 一 ( 共 15 分 ) 阅 读 以 下 说 明 和 流 程 图, 填 补 流 程 图 中 的 空 缺 (1)~(9), 将 解 答 填 入 答 题 纸 的 对 应 栏 内 [ 说 明

More information

ebook35-21

ebook35-21 21 Linux L i n u x 211 U N I X U N I X I / O F I F O U N I X I n t e r n e t s o c k e t () s o c k e t () send() r e c v ( read() w r i t e () send() r e c v () I n t e r n e t 212 Internet Internet S

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

Microsoft PowerPoint - Lecture7II.ppt

Microsoft PowerPoint - Lecture7II.ppt Lecture 8II SUDOKU PUZZLE SUDOKU New Play Check 軟體實作與計算實驗 1 4x4 Sudoku row column 3 2 } 4 } block 1 4 軟體實作與計算實驗 2 Sudoku Puzzle Numbers in the puzzle belong {1,2,3,4} Constraints Each column must contain

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 - 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

投影片 1

投影片 1 資料庫管理程式 ( 補充教材 -Part2) 使用 ADO.NET 連結資料庫 ( 自行撰寫程式碼 以實現新增 刪除 修改等功能 ) Private Sub InsertButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsertButton.Click ' 宣告相關的 Connection

More information

untitled

untitled 1 Outline ArrayList 類 列類 串類 類 類 例 理 MSDN Library MSDN Library 量 例 參 列 [ 說 ] [] [ 索 ] [] 來 MSDN Library 了 類 類 利 F1 http://msdn.microsoft.com/library/ http://msdn.microsoft.com/library/cht/ Object object

More information

untitled

untitled (encapsulation) 例 類 說 類 料 來 料 information hiding 念 (inheritance) 來說 類 類 類 類 類 類 行 利 來 (polymorphism) 不 類 數 不 1 2 3 4 類 類 不 類 不 類 5 6 7 // virtual 不見了 #include #include using namespace

More information

_汪_文前新ok[3.1].doc

_汪_文前新ok[3.1].doc 普 通 高 校 本 科 计 算 机 专 业 特 色 教 材 精 选 四 川 大 学 计 算 机 学 院 国 家 示 范 性 软 件 学 院 精 品 课 程 基 金 青 年 基 金 资 助 项 目 C 语 言 程 序 设 计 (C99 版 ) 陈 良 银 游 洪 跃 李 旭 伟 主 编 李 志 蜀 唐 宁 九 李 涛 主 审 清 华 大 学 出 版 社 北 京 i 内 容 简 介 本 教 材 面 向

More information

华恒家庭网关方案

华恒家庭网关方案 LINUX V1.5 1 2 1 2 LINUX WINDOWS PC VC LINUX WINDOWS LINUX 90% GUI LINUX C 3 REDHAT 9 LINUX PC TFTP/NFS http://www.hhcn.com/chinese/embedlinux-res.html minicom NFS mount C HHARM9-EDU 1 LINUX HHARM9-EDU

More information

untitled

untitled 料 2-1 料 料 x, y, z 料 不 不 料濾 料 不 料 料 不 料 錄 料 2-1 a 料 2-1 b 2003 a 料 b 料 2-1 料 2003 料 料 行 料濾 料亂 濾 料 料 滑 料 理 料 2001 料 兩 理 料 不 TIN, Triangular Irregular Network 8 2-2 a 數 量 料 便 精 2003 料 行 理 料 立 狀 連 料 狀 立 料

More information

Microsoft Word - part doc

Microsoft Word - part doc 3 指標與陣列 3-1 指標與一維陣列 3-2 指標與二維陣列 3-3 陣列指標 3-4 為什麼 parr 等同於 *parr? 3-5 指向陣列的指標 3-6 多重指標 3-7 命令列引數 3-8 除錯題 3-9 問題演練 3-10 程式實作 32 Part 1 C 程式語言篇 指標其實就是一位址 陣列的名稱, 表示此陣列第一個元素的位址, 所以它也是指標 由此可知, 指標與陣列的關係是很密切的

More information

在挑选合适的 SDK 的时候需要注意, 标准 windows 平台应用选择 FBX SDK VS2015,windows 应用商店和全平台通用的不用考虑 windows 全平台通用的应用是 windows10 新推出的功能, 可以打通 windows phone windows s

在挑选合适的 SDK 的时候需要注意, 标准 windows 平台应用选择 FBX SDK VS2015,windows 应用商店和全平台通用的不用考虑 windows 全平台通用的应用是 windows10 新推出的功能, 可以打通 windows phone windows s FBX SDK 安装配置 访问 FBX 网址 :http://www.autodesk.com/products/fbx/overview, 如下 : 点击 GET FBX SDK 进入 SDK 下载页面 ( 网址为 : http://usa.autodesk.com/adsk/servlet/pc/item?siteid=123112&id=25408427): 在挑选合适的 SDK 的时候需要注意,

More information

PowerPoint Presentation

PowerPoint Presentation 資料結構概論 NTU CSIE Outline 資料結構概論 C 語言的結構 (struct) 結構化的資料常見的資料結構簡介 從一個例子開始 算出班上十位同學成績之總分與平均 #include int main() // 宣告變數與資料內容 int a0=80, a=90, a2=70, a3=66, a4=56; int a5=99, a6=88, a7=50, a8=60,

More information

mvc

mvc Build an application Tutor : Michael Pan Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist - UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication

More information

NOWOER.OM m/n m/=n m/n m%=n m%n m%=n m%n m/=n 4. enum string x1, x2, x3=10, x4, x5, x; 函数外部问 x 等于什么? 随机值 5. unsigned char *p1; unsigned long *p

NOWOER.OM m/n m/=n m/n m%=n m%n m%=n m%n m/=n 4. enum string x1, x2, x3=10, x4, x5, x; 函数外部问 x 等于什么? 随机值 5. unsigned char *p1; unsigned long *p NOWOER.OM /++ 程师能 评估. 单项选择题 1. 下 描述正确的是 int *p1 = new int[10]; int *p2 = new int[10](); p1 和 p2 申请的空间 的值都是随机值 p1 和 p2 申请的空间 的值都已经初始化 p1 申请的空间 的值是随机值,p2 申请的空间 的值已经初始化 p1 申请的空间 的值已经初始化,p2 申请的空间 的值是随机值 2.

More information

38 47995529 威 福 髮 藝 店 桃 園 市 蘆 竹 區 中 山 里 福 祿 一 街 48 號 地 下 一 樓 50,000 獨 資 李 依 純 105/04/06 府 經 登 字 第 1059003070 號 39 47995534 宏 品 餐 飲 桃 園 市 桃 園 區 信 光 里 民

38 47995529 威 福 髮 藝 店 桃 園 市 蘆 竹 區 中 山 里 福 祿 一 街 48 號 地 下 一 樓 50,000 獨 資 李 依 純 105/04/06 府 經 登 字 第 1059003070 號 39 47995534 宏 品 餐 飲 桃 園 市 桃 園 區 信 光 里 民 1 08414159 惠 鴻 眼 鏡 行 桃 園 市 中 壢 區 福 德 里 中 華 路 一 段 186 號 1 樓 30,000 獨 資 宋 耀 鴻 105/04/27 府 經 登 字 第 1059003866 號 2 17891110 承 元 冷 氣 空 調 工 程 行 桃 園 市 桃 園 區 中 德 里 國 際 路 1 段 98 巷 50 號 2 樓 之 4 200,000 獨 資 詹 安 平

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

Microsoft Word - 4.doc

Microsoft Word - 4.doc 緩衝區管理 4.1 概念 : 緩衝區 指標以及位元組順序 4.2 緩衝區管理函數 ANSI C 技術手冊 4.1 概念 : 緩衝區 指標以及位元組順序 為了有效率地使用緩衝區 (buffer) 管理函數, 首先需要熟悉緩衝區 指標和位元組順序的概念 緩衝區 緩衝區是電腦記憶體中一組連續的位元組 緩衝區的內容可以是大多數函數所要處理的 ASCII 字元, 或是數值 如圖 4-1 所示, 緩衝區是藉由指向第一個位元組的指標來存取

More information

chap07.key

chap07.key #include void two(); void three(); int main() printf("i'm in main.\n"); two(); return 0; void two() printf("i'm in two.\n"); three(); void three() printf("i'm in three.\n"); void, int 标识符逗号分隔,

More information

Microsoft PowerPoint - Class2.pptx

Microsoft PowerPoint - Class2.pptx C++ 程式初探 II 2015 暑期 C++ 程式 II 大綱 1. 變數 2. 運算式 3. 輸出 4. 條件判斷 5. 迴圈 6. 陣列 2 基本變數型態 整數 位元組 浮點數 位元組 字元 位元組 short 2 float 4 char ( 整數 ) 1 int 2 (4) double 8 long 4 (8) long double 8(10) 位元組 整數値域 浮點數値域 準確度 1-128

More information

untitled

untitled 1 MSDN Library MSDN Library 量 例 參 列 [ 說 ] [] [ 索 ] [] 來 MSDN Library 了 類 類 利 F1 http://msdn.microsoft.com/library/ http://msdn.microsoft.com/library/cht/ Object object 參 類 都 object 參 object Boxing 參 boxing

More information

摘 要 就 一 个 游 戏 而 言, 对 于 参 与 者, 需 要 研 究 不 同 的 策 略 去 达 到 胜 利, 而 对 于 游 戏 设 计 者, 则 需 要 研 究 这 个 游 戏 的 平 衡 性 与 记 分 规 则 的 合 理 性, 并 不 断 去 调 整 它 们 在 本 文 中, 我 们

摘 要 就 一 个 游 戏 而 言, 对 于 参 与 者, 需 要 研 究 不 同 的 策 略 去 达 到 胜 利, 而 对 于 游 戏 设 计 者, 则 需 要 研 究 这 个 游 戏 的 平 衡 性 与 记 分 规 则 的 合 理 性, 并 不 断 去 调 整 它 们 在 本 文 中, 我 们 三 国 杀 游 戏 平 衡 性 与 记 分 规 则 合 理 性 分 析 报 告 摘 要 就 一 个 游 戏 而 言, 对 于 参 与 者, 需 要 研 究 不 同 的 策 略 去 达 到 胜 利, 而 对 于 游 戏 设 计 者, 则 需 要 研 究 这 个 游 戏 的 平 衡 性 与 记 分 规 则 的 合 理 性, 并 不 断 去 调 整 它 们 在 本 文 中, 我 们 将 站 在 游 戏 设

More information

Microsoft PowerPoint - ds-1.ppt [兼容模式]

Microsoft PowerPoint - ds-1.ppt [兼容模式] http://jwc..edu.cn/jxgl/ HomePage/Default.asp 2 说 明 总 学 时 : 72( 学 时 )= 56( 课 时 )+ 16( 实 验 ) 行 课 时 间 : 第 1 ~14 周 周 学 时 : 平 均 每 周 4 学 时 上 机 安 排 待 定 考 试 时 间 : 课 程 束 第 8 11 12 章 的 内 容 为 自 学 内 容 ; 目 录 中 标 有

More information

C/C++语言 - 分支结构

C/C++语言 - 分支结构 C/C++ Table of contents 1. if 2. if else 3. 4. 5. 6. continue break 7. switch 1 if if i // colddays.c: # include int main ( void ) { const int FREEZING = 0; float temperature ; int cold_ days

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

untitled

untitled 1 Outline 流 ( ) 流 ( ) 流 ( ) 流 ( ) 流 ( ) 狀 流 ( ) 利 來 行流 if () 立 行 ; else 不 立 行 ; 例 sample2-a1 (1) 列 // 料 Console.Write(""); string name = Console.ReadLine(); Console.WriteLine(" " + name + "!!"); 例 sample2-a1

More information

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

More information

51 C 51 isp 10 C PCB C C C C KEIL

51 C 51 isp 10   C   PCB C C C C KEIL http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown http://wwwispdowncom

More information

立 志 于 打 造 最 贴 近 考 生 实 际 的 辅 导 书 计 算 机 考 研 之 数 据 结 构 高 分 笔 记 率 辉 编 著 周 伟 张 浩 审 核 讨 论 群 :15945769

立 志 于 打 造 最 贴 近 考 生 实 际 的 辅 导 书 计 算 机 考 研 之 数 据 结 构 高 分 笔 记 率 辉 编 著 周 伟 张 浩 审 核 讨 论 群 :15945769 立 志 于 打 造 最 贴 近 考 生 实 际 的 辅 导 书 计 算 机 考 研 之 数 据 结 构 高 分 笔 记 率 辉 编 著 周 伟 张 浩 审 核 讨 论 群 :15945769 前 言 在 计 算 机 统 考 的 四 门 专 业 课 中, 最 难 拿 高 分 的 就 是 数 据 结 构 但 是 这 门 课 本 身 的 难 度 并 不 是 考 生 最 大 的 障 碍, 真 正 的 障 碍

More information

C6_ppt.PDF

C6_ppt.PDF C01-202 1 2 - (Masquerade) (Replay) (Message Modification) (Denial of Service) - ( ) (Eavesdropping) (Traffic Analysis) 8 1 2 7 3 6 5 4 3 - TCP SYN (SYN flood) Smurf Ping of Death LAND Attack Teardrop

More information

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO Car DVD New GUI IR Flow User Manual V0.1 Jan 25, 2008 19, Innovation First Road Science Park Hsin-Chu Taiwan 300 R.O.C. Tel: 886-3-578-6005 Fax: 886-3-578-4418 Web: www.sunplus.com Important Notice SUNPLUS

More information

untitled

untitled 1 Outline 料 類 說 Tang, Shih-Hsuan 2006/07/26 ~ 2006/09/02 六 PM 7:00 ~ 9:30 聯 ives.net@gmail.com www.csie.ntu.edu.tw/~r93057/aspnet134 度 C# 力 度 C# Web SQL 料 DataGrid DataList 參 ASP.NET 1.0 C# 例 ASP.NET 立

More information

第11章 可调内核参数

第11章 可调内核参数 11 11 Unix BSD 4.4 Linux sysctl Unix Linux /proc window /proc /proc/sys /proc/sys sysctl Unix root /proc/sys/vm root /proc/sys sysctl /proc/sys struct ctl_table 18274 struct ctl_tables /proc/sys struct

More information

C 語言—陣列及字串

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

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

第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

Microsoft Word - 01.DOC

Microsoft Word - 01.DOC 第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的

More information

Microsoft Word - data_mid1611_and_sol.docx

Microsoft Word - data_mid1611_and_sol.docx Department of Computer Science and Engineering National Sun Yat-sen University Data Structures - Middle Exam, Nov. 14, 2016 1. Explain each of the following terms. (16%) (a) private in C++ language (b)

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

1

1 基本練習題 1. 答 : 鄰接矩陣 : D E D E 0 0 1 0 1 0 0 0 0 1 1 0 0 1 1 0 0 1 0 1 1 1 1 1 0 5 5 D E D E 0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 0 0 鄰接串列 : List[] List[] E List[] E List[] D E List[D] E List[E]

More information

2. 參考網站 C 語言考古題 & C 的解題 程式設計學習入門 ( 網址 : c.blogspot.com/) 網站 : 星子 ACM 小窩 ( 網址 : 網站 :ACM Onli

2. 參考網站 C 語言考古題 & C 的解題 程式設計學習入門 ( 網址 :  c.blogspot.com/) 網站 : 星子 ACM 小窩 ( 網址 :  網站 :ACM Onli 壹 課程說明 單元名稱 單元摘要 C 語言 : 進階資料型態 1. 認識陣列 (Array) 2. 認識結構 (Structure) 3. 認識指標 (Pointer) 設計者劉洲溶教師 ( 國立台中二中 ) 1. 了解陣列的含意及學習陣列宣告語法及程式設計方法 2. 了解結構的意義及學習結構宣告語法及程式設計方法 學習目標 3. 了解指標的含意及學習指標宣告語法及程式設計方法 4. 培養學生進階程式設計能力

More information

Microsoft PowerPoint - C-Ch12.ppt

Microsoft PowerPoint - C-Ch12.ppt 檔案的輸入 輸出 12-1 輸入 輸出的基礎 理解資料流 (stream) 的概念 在 C 語言中支援各種輸出入功能的概念, 就稱為資料流 執行附加格式的輸入 輸出 printf() 和 scanf() 是用來輸出 輸入的函數 必須先引入 stdio.h 檔案才能使用這些函數 這兩個函數會以固定的格式進行輸出入, 也可以使用各種不同的轉換規格 使用固定格式的輸出 輸入函數之範例 : int main(void)

More information

Chapter 1 What is Programing Paradigm 1

Chapter 1 What is Programing Paradigm 1 An Introduction to Programing Paradigm Chase Zhang May 8, 2013 Chapter 1 What is Programing Paradigm 1 CHAPTER 1. WHAT IS PROGRAMING PARADIGM 2 Definition from Wikipedia 1. Object-oriented programming/

More information

OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢 学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料

OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢   学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢 Email: 51141201063@ecnu.cn 学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料 OOP with Java Java 类型 引用 不可变类型 对象存储位置 作用域 OOP

More information

Microsoft PowerPoint - L17_Inheritance_v4.pptx

Microsoft PowerPoint - L17_Inheritance_v4.pptx C++ Programming Lecture 17 Wei Liu ( 刘 威 ) Dept. of Electronics and Information Eng. Huazhong University of Science and Technology May. 2015 Lecture 17 Chapter 20. Object-Oriented Programming: Inheritance

More information

提问袁小兵:

提问袁小兵: C++ 面 试 试 题 汇 总 柯 贤 富 管 理 软 件 需 求 分 析 篇 1. STL 类 模 板 标 准 库 中 容 器 和 算 法 这 部 分 一 般 称 为 标 准 模 板 库 2. 为 什 么 定 义 虚 的 析 构 函 数? 避 免 内 存 问 题, 当 你 可 能 通 过 基 类 指 针 删 除 派 生 类 对 象 时 必 须 保 证 基 类 析 构 函 数 为 虚 函 数 3.

More information