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

Size: px
Start display at page:

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

Transcription

1 C/C++ 基礎程式設計 結構 檔案處理 (Structure, File) 講師 : 張傑帆 CSIE, NTU 人這輩子沒辦法做太多事, 所以每一件事情都要做到精采絕倫 In your life you only get to do so many things. Right now we ve chosen to do this. So let s make it great. -Steve Jobs

2 課程大綱 結構 檔案概論 作業

3 思考一下 如果你想用程式存一個人的姓名 身高 體重你會怎麼寫? #include <stdio.h> int main() char name[80]; int height; int weight; scanf("%s",&name); scanf("%d",&height); scanf("%d",&weight);

4 思考一下 那 2 個人呢? #include <stdio.h> int main() char p1name[80]; int p1height; int p1weight; char p2name[80]; int p2height; int p2weight; scanf("%s",&p1name); scanf("%d",&p1height); scanf("%d",&p1weight); scanf("%s",&p2name); scanf("%d",&p2height); scanf("%d",&p2weight);

5 思考一下 那 10 個人呢? 因此我們需要更方便管理的變數來儲存資料 : 結構化資料 #include <stdio.h> int main() char p1name[80]; int p1height; int p1weight; char p2name[80]; int p2height; int p2weight;

6 思考一下 那 10 個人呢? 如果用陣列來存 因此我們需要更方便管理的變數來儲存資料 : 結構化資料 #include <stdio.h> int main() char name[10][80]; int height[10]; int weight[10]; int score[10]; // 十家店評分, 與人無關

7 結構 (structure) 通常一個簡單之變數或陣列不足以用來儲存複雜之記錄 我們用過了 int, float, double, 也可以使用陣列, 若如果我們想要讓一個變數擁有許多不同的形態呢? C 語言中有結構體之架構, 允許使用者宣告資料實體將不同形式之元素儲存一起 結構是一種由程式設計師自訂之資料型態

8 結構的定義 定義一個結構之語法 struct 結構名稱標籤 資料型態資料變數成員 1; 資料型態資料變數成員 2; ; 結構的標籤名稱 (tag) struct Person char name[80]; int height; int weight; ; 可看成是一個程式設計師自訂的新型態 結構的成員 (member) 其資料型態可以使用 int, float 及 char 也可用陣列與指標或是另外一個結構

9 結構 範例 : struct Person char name[80]; int height; int weight; ; struct Person p; // 這行在 main 裡面 P struct Person: 88 bytes name[ 0] name[ 1] name[7 9] height weight 80 bytes int : 4 bytes int : 4 bytes

10 結構的宣告與使用 宣告一個結構實體之語法 struct 結構名稱標籤結構實體名稱 ; struct 結構名稱標籤結構實體名稱 = 初始值 1, 初始值 2, ; 結構中成員的使用之語法 結構實體之成員的直接存取 結構實體. 成員名稱 結構指標之成員的直接存取 struct Person p1 = John, 180, 75; p1.height = 180; p1.weight = 75; 結構指標 -> 成員名稱 = (* 結構指標 ). 成員名稱 struct Person p1; struct Person *p2; p2 = &p1; p2->height = 180; (*p2).weight = 75;

11 結構 在 C 語言中, 有提供一個比較好的方法來自己定義出一群變數的組合 #include <stdio.h> struct Person char name[80]; int height; int weight; ; int main() struct Person p1; struct Person p2; scanf("%s",&p1.name); scanf("%d",&p1.height); scanf("%d",&p1.weight); printf("name:%s\nheight:%d cm\nweight:%d kg\n",p1.name,p1.height,p1.weight); scanf("%s",&p2.name); scanf("%d",&p2.height); scanf("%d",&p2.weight); printf("name:%s\nheight:%d cm\nweight:%d kg\n",p2.name,p2.height,p2.weight);

12 結構的指標 範例 : 使用結構指標存取另一個結構的資料 #include <stdio.h> struct Person char name[80]; int height; int weight; ; int main() struct Person p1; struct Person *p2; p2 = &p1; gets(p2->name); scanf("%d",&p2->height); scanf("%d",&p2->weight);

13 結構陣列 結構也可宣告成陣列, 方便做重覆控制 #include <stdio.h> #define PEOPLE 2 struct Person char name[80]; int height; int weight; ; int main() struct Person p[people]; int i; for (i=0; i < PEOPLE; i++ ) scanf("%s", &p[i].name ); scanf("%d", &p[i].height ); scanf("%d", &p[i].weight ); printf("name:%s\nheight:%d\nweight:%d\n", p[i].name, p[i].height, p[i].weight);

14 typedef typedef 可以把所有 C 語言中的型態改用程式設計師自己取的名字來取代 #include <stdio.h> typedef unsigned char UINT8; typedef unsigned short UINT16; typedef unsigned long UINT32; int main() UINT8 a=1; UINT16 b=2; UINT32 c=3;

15 typedef 用 typedef 來自訂一個型態, 常用在結構上 #include <stdio.h> #define PEOPLE 2 struct _Person char name[80]; int height; int weight; ; typedef struct _Person Person; int main() Person p[people]; int i; for (i=0; i < PEOPLE; i++ ) scanf("%s", &p[i].name ); scanf("%d", &p[i].height); scanf("%d", &p[i].weight ); printf("name:%s\nheight:%d\nweight:%d\n", p[i].name, p[i].height, p[i].weight);

16 小練習 請寫一程式可以連續儲存 3 名公司職員的姓名 電話與職員編號, 並可依職員編號查尋 struct Employee char Name[20]; char Phone[11]; int Id; ;

17 課程大綱 結構 檔案概論 作業

18 檔案處理 從檔案讀進資料或將結果存入檔案之中 fscanf 從檔案讀進資料 fprintf 將結果存入檔案

19 檔案處理 範例 : 從 input.txt 讀一字串到 str, 再把字串從 str 寫到 output.txt #include <stdio.h> int main() FILE *in, *out; char str[80]; in = fopen("input.txt", "r"); fscanf(in, "%s", &str); fclose(in); //in, out 為檔案指標 // 開啟 input.txt // 讀檔 // 關閉 input.txt out = fopen("output.txt", "w"); // 開啟 output.txt fprintf(out, "%s", str); // 寫 fclose(out); // 關閉 output.txt

20 fopen(): 開檔 檔案使用前需要先開啟, 開檔結果需要檔案指標 FILE 紀錄相關資訊, 之後即可使用該指標讀寫檔 使用格式 : 檔案指標 = fopen( 檔名, 模式 ); 檔名 : 檔案指標, 指的是欲開啟的檔案名稱 模式 : 檔案使用模式, 指的是檔案被開啟之後, 它的使用方式 模式 r 開啟一個文字檔 (text), 供程式讀取 "w" 開啟一個文字檔 (text), 供程式將資料寫入此檔案內 如果磁碟內不包含這個檔案, 則系統會自行建立這個檔案 如果磁碟內包含這個檔案, 則此檔案內容會被覆蓋而消失 "a" 開啟一個文字檔 (text), 供程式將資料寫入此檔案的末端 如果此檔案不存在, 則系統會自行建立此檔案 "rb" 開啟一個二元檔 (binary), 供程式讀取 "wb" 開啟一個二元檔, 供程式將資料寫入此檔案內 如果磁碟內不包含這個檔案, 則系統會自行建立這個檔案 如果磁碟內包含這個檔案, 此檔案內容會被蓋過而消失 "ab" 開啟一個二元檔 (binary), 供程式將資料寫入此檔案末端, 如果此檔案不存在, 則系統會自行建立此檔案

21 判斷檔案開啟是否正確 使用 fopen 若開檔失敗, 會回傳一個 NULL 結果 常用來判斷檔案是否存在! #include <stdio.h> int main() FILE *in, *out; char str[80]; in = fopen("input.txt", "r"); if(in == NULL) printf("failed to open file!\n"); out = fopen("output.txt", "w"); fscanf(in, "%s", &str); fprintf(out, "%s", str); fclose(in); fclose(out);

22 相對路徑與絕對路徑 相對路徑 相對於現在目錄的路徑表示法, 因此 相對路徑 所指到的檔案或目錄, 會隨著現執行的這支程式所在目錄的不同而改變 假設當前程式所在目錄於 E:\test\file 22./ 表示當前路徑, 相當於 E:\test\file../ 表示當前路徑的上一級路徑, 相當於 E:\test data 表示當前路徑下一級路徑的 data 資料夾中, 相當於 E:\test\file\data

23 相對路徑與絕對路徑 絕對路徑 指的是一個絕對的位置, 並不會隨著現在執行的程式所在目錄的改變而改變 EX: E:\test E:\test\file E:\test\file\data

24 fprintf(): 寫檔 將資料, 以格式化方式寫入某檔案內 使用格式 : fprintf( 檔案指標," 格式化輸出內容 ", 參數 1, 參數 2,... 參數 n); 格式化輸出內容 : 可加入列印格式 控制字元 修飾子 參數 : 為對應格式之變數 此格式化輸出內容與參數的使用, 格式和 printf( ) 使用格式相同

25 fclose(): 關檔 用於關閉檔案, 如果 fclose( ) 執行失敗, 它的傳回值是非零值 使用格式 : fclose( 檔案指標 ); 在 C 語言中關閉檔案主要有三個目的 : 檔案在關閉前會將檔案緩衝區資料寫入磁碟檔案內, 否則檔案緩衝區資料會遺失 ( 因為磁碟 IO 會比較慢, 所以需要緩衝區 ) 使用相同的檔案指標時, 檔案換個模式開啟時 ( 例 : 先寫後讀 ) 解除已開啟檔案的鎖定狀態

26 int main() FILE *output; int i; output=fopen("test.txt", "w"); for (i=0; i<10; i++ ) fprintf( output, "%d\n",i); //fflush(output); fclose(output); 關檔時檔案才真正寫入 通常, 在呼叫 fclose 之前, 檔案的內容不會真正的被寫到磁碟機上 若要強迫馬上寫入, 可以呼叫 fflush(file *) 來做到 #include <stdio.h> #include <stdlib.h>

27 fprintf(): 寫檔 範例 : 將陣列個數與內容寫入指定名稱之檔案 #include <stdio.h> int main() FILE *file; int a[5] = 10, 20, 30, 40, 50; char str[80]; int i, n=5; // 開檔 printf("input file name: "); scanf("%s", &str); file = fopen(str, "w"); // 寫檔 fprintf(file, "%d\n", n); for(i=0; i<n; i++) fprintf(file, "%d ", a[i]); // 關檔 fclose(file);

28 fscanf(): 讀檔 從某個檔案讀取資料 使用格式 : fscanf( 檔案指標, " 格式化輸入內容 ", & 參數 1, & 參數 2,...& 參數 n); 格式化輸入內容 : 可加入列印格式 控制字元 修飾子 參數 : 對應格式之變數 此格式化輸入內容與參數的使用, 格式和 scanf( ) 使用格式相同

29 fscanf(): 讀檔 範例 : 將指定名稱之檔案的陣列個數與內容讀出並印到螢幕上 #include <stdio.h> int main() FILE *file; int a[100]; char str[80]; int i, n; // 開檔 printf("input file name: "); scanf("%s", &str); file = fopen(str, "r"); if(file == NULL) printf("open file fail!\n"); // 讀檔 fscanf(file, "%d", &n); for(i=0; i<n; i++) fscanf(file, "%d ", &a[i]); // 輸出 printf("%d\n", n); for(i=0; i<n; i++) printf("%d ", a[i]); printf("\n"); // 關檔 fclose(file);

30 小練習 請將上述讀檔與寫檔的例子修改成浮點數版 ( 小數點 ) 30

31 判斷檔案是否結束 feof( 檔案指標 ); 範例 : 寫作一個讀檔程式將檔案內容印到螢幕上 #include <stdio.h> int main() FILE *input; char str[80]; char ch; scanf("%s", &str); input=fopen(str,"r"); if ( input==null ) printf("open input.txt fail!\n"); while(1) fscanf(input, "%c", &ch); if( feof(input) ) break; printf("%c", ch);

32 課程大綱 結構 檔案概論 作業

33 作業 製作一個通訊錄程式 功能 輸入 i 可輸入姓名, 電話, 輸入 l 印出目前輸入所有人員之內容 輸入 s 輸入檔名, 將所有人員之內容存入檔案 輸入 o 輸入檔名, 將所有人員之內容從檔案讀出 輸入 q 離開程式 輸入之人數上限為 50 人 輸入格式 輸入輸出介面與下面範例相同, 檔案格式不拘 參考範例 :

34 延申閱讀 union 共同空間 enum 列舉型態 讀寫 CSV 檔 二進位檔 fwrite() fread() 隨機存取 fseek() 使用 fscanf() 函數 fprintf() 函數, 可以進行固定條件的資料流輸出 輸入 使用 fgets() 函數 fputs() 函數, 可以進行單行的資料流輸出 輸入 使用 fgetc() 函數 putc() 函數, 可以進行單一字元的資料流輸出 輸入 使用 fopen() 函數 fclose() 函數, 可以進行檔案的開啟 關閉 使用 fread() 函數 fwrite() 函數, 可以進行指定資料大小的輸出 輸入 使用 fseek() 函數, 可以移動檔案位置

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

プログラムの設計と実現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

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

新・解きながら学ぶ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

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

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

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

C/C++ Programming !281 第 十講 檔案輸入與輸出 講師 : 李根逸 (Ken-Yi Lee), E-mail: feis.tw@gmail.com !282 課程 大綱 與作業系統或其他軟體溝通 (API) [P.283] 檔案相關函式表 [P.284] 開啟與關閉檔案 (fopen, fclose) 讀寫純 文字檔 (fscanf, fprintf) 讀寫 二進位檔 (fread, fwrite)

More information

C/C++ Basics

C/C++ Basics 第 十章 檔案輸入與輸出 講師 : 李根逸 (Ken-Yi Lee), E-mail: feis.tw@gmail.com 265 課程 大綱 與作業系統或其他軟體溝通 (API) [P267] 檔案相關函式表 [P268] 開啟與關閉檔案 (fopen, fclose) 讀寫純 文字檔 (fscanf, fprintf) 讀寫 二進位檔 (fread, fwrite) 前置處理器

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

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

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

More information

Microsoft Word - chap13.doc

Microsoft Word - chap13.doc ï FILE dã Ä o rô qî ô Ö ƒù å o ô ÃÓ FILE Ã Ù Ö o v-> ª w ï FILE d wã +1 ~ c:\temp w Õx test.dat Ã Û vä à n ïw à test.dat 13-2a /* File name: ex13-2a.c */ #include char ch; fptr = fopen("c:\\temp\\test.dat",

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

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

PowerPoint Presentation

PowerPoint Presentation C/C++ 資料結構與程式設計檔案處理 NTU CSIE 講師 : 張傑帆 檔案函式簡介 C 語言所提供的檔案處理函式, 將這些輸入的資料儲存在指定的資料檔 (Data File) 中, 這些資料檔的副檔名通常設為 *.txt 或 *.dat 當需要處理資料檔中的資料時, 可以透過檔案處理函式, 取得資料檔內的資料並存放到變數或陣列 ( 主記憶體中 ) 中進行處理, 資料處理完畢再將資料寫回指定的資料檔內

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

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

Microsoft PowerPoint - C-Ch12.ppt

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

More information

C_Ch12

C_Ch12 第十二章 檔案輸入輸出 學習目標 : 了解檔案的讀寫原理 熟悉標準 I/O 函式 能隨機存取檔案內容 了解系統 I/O 函式 熟悉中文字處理 Turbo C 範例教本第二版投影片學貫行銷出版 www.xbook.com.tw 林新德版權所有 shinder.lin@gmail.com 檔案的基本認識 C 將檔案視為一連串的資料 (stream of data, 或稱資料流 ) 資料以位元組 (byte)

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 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++语言 - 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

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

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

文件

文件 CH10 文件 1 文件的概念 一 文件分类 二 文件的组织结构 : ASCII 码文件 ( 文本文件 ) 二进制文件 文件是二进制代码的, 则文件就是字节流 文件是 ASCII 码的, 则文件就是字符流, 也是字节流 1 如 : 对于整型变量 x, 其值为 32767 若以文本方式存放, 则共有 5 个字符, 内容为 : 00110011 00110010 00110111 00110110 00110111

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

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

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

IO

IO 1 C/C++ C FILE* fscanf fgets fread fprintf fputs fwrite C++ ifstream ofstream >>

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

Ps22Pdf

Ps22Pdf ( 98 ) C ( ) ( )158 1998 C : C C C,,, C,, : C ( ) : : (, 100084) : : : 7871092 1/ 16 :18 25 :415 : 2000 3 1 2000 3 1 : ISBN 7 302 01166 4/ T P432 : 00016000 : 22 00 ( 98 ) 20 90,,, ;,,, 1994, 1998, 160,

More information

White Sketchpad PowerPoint Presentation

White Sketchpad PowerPoint Presentation 第五章 檔案存取 電商三乙 4A355001 郭雅如 4A355063 周宛萱 5-1-1 取得檔案名稱 但排除副檔名 5-1-2 取得路徑資訊

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

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

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

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

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

碩命題橫式

碩命題橫式 一 解釋名詞 :(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

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++ 基礎程式設計 指標 (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

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

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

( 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

华恒家庭网关方案

华恒家庭网关方案 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

Microsoft Word - CPE考生使用手冊160524.docx

Microsoft Word - CPE考生使用手冊160524.docx 大 學 程 式 能 力 檢 定 (CPE) 考 生 使 用 手 冊 2016 年 5 月 24 日 這 份 手 冊 提 供 給 參 加 CPE 檢 定 考 試 的 考 生 內 容 包 含 考 試 環 境 的 使 用, 以 及 解 題 時 所 使 用 I/O 的 基 本 知 識 1. 如 欲 報 名 參 加 CPE 考 試, 請 先 於 CPE 網 站 完 成 帳 號 註 冊, 然 後 再 報 名 該

More information

2015年计算机二级(C语言)模拟试题及答案(四)

2015年计算机二级(C语言)模拟试题及答案(四) 2016 年 计 算 机 二 级 (C 语 言 ) 模 拟 试 题 及 答 案 (4) 一 填 空 题 1 C 语 言 中 基 本 的 数 据 类 型 有 : 2 C 语 言 中 普 通 整 型 变 量 的 类 型 说 明 符 为, 在 内 存 中 占 字 节, 有 符 号 普 通 整 型 的 数 据 范 围 是 3 整 数 -35 在 机 内 的 补 码 表 示 为 4 执 行 下 列 语 句 int

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

chap12.ppt

chap12.ppt 第十二章 文件 C ( 前所讲 ) 程序 ( 可包含若干源程序文件 ) 文件 也属于. 目的 : 使程序操作中的数据得以长期保存 一 概述 OS 以文件为单位对数据进行存储管理 流与文件流 :C 提供的一个 I/O 统一接口, 与具体的被访问设备无关 把 I/O 工作抽象成从源到目地的流, 所有的 I/O 通过流来进行, 所有流都具有相同的行为 文件 : 指具体的实际设备 ( 一切具有 I/O 能力的外部设备

More information

Microsoft Word - 考试大纲-2015-56(2)

Microsoft Word - 考试大纲-2015-56(2) 考 试 大 纲 2015 版 首 都 师 范 大 学 信 息 工 程 学 院 目 录 C 语 言 程 序 设 计 考 试 大 纲... 1 DSP 原 理 与 应 用 考 试 大 纲... 7 DSP 原 理 与 应 用 实 验 考 试 大 纲... 9 SOPC 设 计 与 实 践 考 试 大 纲... 10 编 译 原 理 考 试 大 纲... 15 操 作 系 统 考 试 大 纲... 23

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

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

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

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 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++入門編 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

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

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

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

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

C/C++ Programming 265 第九講 結構 講師 : 李根逸 (Ken-Yi Lee), E-mail: feis.tw@gmail.com 266 課程 大綱 結構 (struct) 結構宣告 [P.267] 結構定義 [P.268] 結構變數宣告 [P.269] 結構變數的初始化 [P.272] 存取結構成員 [P.244] 傳送 大型資料型態參數 [P.277] 267 結構宣告 結構是 一種衍 生的 自訂資料型態,

More information

上海市教育考试院关于印发新修订的

上海市教育考试院关于印发新修订的 沪 教 考 院 社 考 2012 7 号 上 海 市 教 育 考 试 院 关 于 印 发 上 海 市 高 等 学 校 计 算 机 等 级 考 试 大 纲 (2012 年 修 订 ) 的 通 知 各 有 关 高 校 : 为 进 一 步 加 强 本 市 高 校 计 算 机 基 础 教 学 工 作, 推 进 学 校 更 加 科 学 合 理 地 设 置 计 算 机 基 础 课 程 及 安 排 教 学 内 容,

More information

PowerPoint Presentation

PowerPoint Presentation 陣列與鏈結串列 NTU CSIE Outline 結構陣列鏈結串列 單向鏈結串列之資料型態 單向鏈結串列之基本運算 作業 結構陣列 優點 缺點 使用容易 刪除與插入造成資料移動頻繁浪費不必要之記憶體陣列長度為常數, 可能會不夠用 #include struct _student int math; int english; int computer; ; typedef struct

More information

3.1 num = 3 ch = 'C' 2

3.1 num = 3 ch = 'C' 2 Java 1 3.1 num = 3 ch = 'C' 2 final 3.1 final : final final double PI=3.1415926; 3 3.2 4 int 3.2 (long int) (int) (short int) (byte) short sum; // sum 5 3.2 Java int long num=32967359818l; C:\java\app3_2.java:6:

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 第 13 章外存中数据的组织 文件 本章的基本内容是 : 概述 文件的打开与关闭 文件的读写操作 任务 13.1 统计入学成绩 ( 文件版 ) 问题 某大学的博士入学考试科目为外语和两门专业课, 对于每个考生, 输入各科考试成绩并计算总分 要求用文件实现 想法 已经录入的成绩信息应该用文件保存下来, 已经计算的总分也应该保存到文件中, 并已追加方式继续录入 算法 文件 student.txt 存放学生的成绩信息,

More information

第7章 数组

第7章  数组 第 12 章文件 内容 自定义类型 (typedef) 文件是什么?C 语言如何处理文件? 文本文件和二进制文件 打开 关闭文件 文件读写程序 其它相关函数 2 内容 自定义类型 (typedef) 文件是什么?C 语言如何处理文件? 文本文件和二进制文件 打开 关闭文件 文件读写程序 其它相关函数 3 自定义类型 (typedef) 自定义类型 (typedef) typedef < 已有类型名

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

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 串 串 例 : 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

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

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

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp 01 1.6 Spyder Anaconda Spyder Python Spyder Python Spyder Spyder 1.6.1 Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Spyder Python File

More information

Microsoft PowerPoint - CH02 Introduction to C++ Programming_輸入與輸出 [相容模式]

Microsoft PowerPoint - CH02 Introduction to C++ Programming_輸入與輸出 [相容模式] Ch2. Introduction to C++ Programming 輸入與輸出 標準 I/O 課程名稱 : 程式設計 Computer Programming 班級 : 資管一 Freshman, ISMS 任課教師 : 謝明哲 Hsieh, Ming-Che, Miller 單位職稱 : 台東大學資管系副教授 Associate Professor, ISMS, NTTU 電子郵件 :hmz@nttu.edu.tw

More information

FY.DOC

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

More information

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

More information

主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new

主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new ListView 自訂排版 主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new int[]{r.drawable.dog1, R.drawable.dog2,

More information

C 語言—陣列及字串

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

More information

实际问题 : 1 职工信息管理系统 2 学生选课系统 3 飞机订票系统 4 图书信息管理系统 5 图象处理

实际问题 : 1 职工信息管理系统 2 学生选课系统 3 飞机订票系统 4 图书信息管理系统 5 图象处理 实际问题 : 1 职工信息管理系统 2 学生选课系统 3 飞机订票系统 4 图书信息管理系统 5 图象处理 10.1 C 文件概述 文件 : 存储在外部介质上数据的集合, 是操作系统数据管理的单位使用数据文件的目的 文件分类 1 数据文件的改动不引起程序的改动 程序与数据分离 2 不同程序可以访问同一数据文件中的数据按文件的逻辑结构 : 数据共享 3 能长期保存程序运行的中间数据或结果数据 记录文件

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

使用手冊

使用手冊 使用手冊 版權所有 2013 年 Microtek International, Inc. 保留所有權利 商標 Microtek MII MiiNDT ScanWizard Microtek International, Inc. Windows Microsoft Corporation 重要須知 Microtek Microtek Windows Microsoft Windows I49-004528

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

C/C++语言 - 运算符、表达式和语句

C/C++语言 - 运算符、表达式和语句 C/C++ Table of contents 1. 2. 3. 4. C C++ 5. 6. 7. 1 i // shoe1.c: # include # define ADJUST 7. 64 # define SCALE 0. 325 int main ( void ) { double shoe, foot ; shoe = 9. 0; foot = SCALE * shoe

More information

Microsoft PowerPoint - C-Ch11.ppt

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

More information

Microsoft PowerPoint - VB3

Microsoft PowerPoint - VB3 Visual Basic 6.0 & VB.NET 丙檢設計第一站 資科系林偉川 VB 之 for 指令 for 變數 = 初值 to 終值 step 增值多個指令 Next 中途離開用 if 指令判斷條件成立後 exit for Ex: Q=2, w=100, e=2, s=0 For i = q To w Step e s = s + i Next i 2 1 VB6 提供之內建函數 End 執行結束

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

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

Microsoft Word - 投影片ch11

Microsoft Word - 投影片ch11 Java2 JDK5.0 教學手冊第三版洪維恩編著博碩文化出版書號 pg20210 第十一章抽象類別與介面 本章學習目標認識抽象類別學習介面的使用認識多重繼承與介面的延伸 抽象類別與介面 11-2 11.1 抽象類別 抽象類別的目的是要依據它的格式來修改並建立新的類別 11.1.1 定義抽象類別 定義抽象類別的語法如下 : abstract class 類別名稱 { 宣告資料成員 ; // 定義抽象類別

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

Excel VBA Excel Visual Basic for Application

Excel VBA  Excel Visual Basic for Application Excel VBA Jun5,00 Sub 分頁 () Dim i As Integer Dim Cname As String Dim Code As Variant Set score=thisworkbook.sheets("sheet") Code=Array(" 專北一 "," 專北二 "," 專北三 "," 專桃園 "," 專桃竹 "," 專中苗 ", " 專台中 "," 專台南 ","

More information

プリント

プリント For Higher Customer Satisfaction, We Bridge the SAS System Between Customer s World. YourModelsBuild up Your NextAnalytics 02 Y β0 β1x1 β2x2 ε Y ~ μ σ 2 μ β0 β1x1 β2x2 Y ~ n p logit(p) β0 β1x1 β2x2 logit(p)logit(p)=log(p/(1-p))

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

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

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

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

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

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

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

第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

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

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

More information