Strings

Size: px
Start display at page:

Download "Strings"

Transcription

1 Strings Cheng-Chin Chiang

2 Strings Strings 一串儲存在連續記憶體之字元串 表示法 : 以雙引號圍起 This is a book, I love programming, 字串須有一結束字元 \0 (NULL) 在字串尾,NULL 在 C++ 內為一個內定常數值 H i t h e r e! \0

3 An Array Type of Strings Character Array ( 字元陣列 ) 沿用 C 語言的陣列型態, 陣列元素為字元, 因此常被稱為 C-String 例如 : char str[10]; // 一個可以放 10 個字元的陣列 char message[12]; // 一個可以放 12 個字元的陣列 char message[12]= Hi there! // 宣告和初始化一次完成 char mystring[ ]= abc // 利用初始化來決定陣列大小 (=4) char mystring[ ]={ a, b, c } // 和上例不一樣, 那裏不一樣? 宣告技巧 : H i t h e r e! \0 Char ArrayName[Maximum_C-String_Size+1];

4 An Array Type of Strings Character Array ( 字元陣列 ) 沿用 C 語言的陣列型態, 陣列元素為字元, 因此常被稱為 C-string 例如 : char str[10]; // 一個可以放 10 個字元的陣列 char message[12]; // 一個可以放 12 個字元的陣列 char message[12]= Hi there! // 宣告和初始化一次完成 H i t h e r e! \0 char mystring[ ]= abc // 利用初始化來決定陣列大小 (3 or 4?) char mystring[ ]={ a, b, c } // 和上例不一樣, 那裏不一樣? 宣告技巧 :

5 Pointers to Character Array 指標 (pointer) 經過動態記憶體配置 (dynamic memory allocation) 後, 也可儲存陣列資料, 所以也可以用來儲存一個字元陣列 例如 : char *s; // 需配置記憶體, 大小 = 字串最長長度 +1 s = new char[5]; char *str= ABCDE ; delete [] str; // 宣告 配置 初始化三工作一體成型

6 String Array 字元二維陣列 : char s[4][6]={ Black, White, Red, Green }; 佔用 24 Bytes B l a c k \0 1 W h i t e \0 2 R e d \0 3 G r e e n \0

7 String Array 指標陣列 : char *s[4]={ Black, White, Red, Green }; 佔用 22 Bytes char *s[ ]={ Black, White, Red, Green }; B l a c k \0 1 W h i t e \0 2 R e d \0 3 G r e e n \0

8 = and == with C-strings C-strings 特殊之處 無法直接指定 (assign) 或比較 (compare) char astring[10]; astring = "Hello"; // ILLEGAL! ( = 只能用在宣告的初始化!) 若要做指定, 必須呼叫字串函數 內建函數 ( 定義在標頭檔 <cstring>) cpy 意為拷貝 (copy) 拷貝時電腦不負責檢查陣列大小是否足夠! 程式設計師的責任 若要做比較, 必須呼叫字串函數 char astring[10] = "Hello"; char anotherstring[10] = "Goodbye"; astring == anotherstring; // NOT allowed! 回傳值 >0 cstringa>cstringb =0 cstringa==cstringb <0 cstringa<cstringb

9 C-string Functions: strlen() 取得字串長度 ( 不包含 NULL) char mystring[10] = "dobedo"; cout << strlen(mystring); 傳回 6

10 C-string Functions: strcat() 字串串接 char stringvar[20] = "The rain"; strcat(stringvar, "in Spain"); 結果 : stringvar 變成 The rainin Spain ( 記得要為 stringvar 備好足夠的記憶體空間 )

11 Other Predefined Functions in <cstring>

12 Other Predefined Functions in <cstring>

13 例題 :Using strcpy and strncpy 11 int main() 12 { 13 char x[] = "Happy Birthday to You"; // string length char y[ 25 ]; 15 char z[ 15 ]; strcpy( y, x ); // copy contents of x into y cout << "The string in array x is: " << x 20 << "\nthe string in array y is: " << y << '\n'; // copy first 14 characters of x into z 23 strncpy( z, x, 14 ); // does not copy null character 24 z[ 14 ] = '\0'; // append '\0' to z's contents cout << "The string in array z is: " << z << endl; 27 return 0; // indicates successful termination 28 } // end main The string in array x is: Happy Birthday to You The string in array y is: Happy Birthday to You The string in array z is: Happy Birthday

14 例題 :Concatenating Strings with strcat and strncat 11 int main() 12 { 13 char s1[ 20 ] = "Happy "; // length 6 14 char s2[] = "New Year "; // length 9 15 char s3[ 40 ] = ""; cout << "s1 = " << s1 << "\ns2 = " << s2; 19 strcat( s1, s2 ); // concatenate s2 to s1 (length 15) 21 cout << "\n\nafter strcat(s1, s2):\ns1 = " << s1 << "\ns2 = " << s2; 23 // concatenate first 6 characters of s1 to s3 24 strncat( s3, s1, 6 ); // places '\0' after last character cout << "\n\nafter strncat(s3, s1, 6):\ns1 = " << s1 27 << "\ns3 = " << s3; strcat( s3, s1 ); // concatenate s1 to s3 30 cout << "\n\nafter strcat(s3, s1):\ns1 = " << s1 31 << "\ns3 = " << s3 << endl; 32 return 0; // indicates successful termination 33 } // end main

15 例題 :Concatenating Strings with strcat and strncat s1 = Happy s2 = New Year After strcat(s1, s2): s1 = Happy New Year s2 = New Year After strncat(s3, s1, 6): s1 = Happy New Year s3 = Happy After strcat(s3, s1): s1 = Happy New Year s3 = Happy Happy New Year

16 例題 :Comparing Strings with strcmp and strncmp 14 int main() 15 { 16 char *s1 = "Happy New Year"; 17 char *s2 = "Happy New Year"; 18 char *s3 = "Happy Holidays"; cout << "s1 = " << s1 << "\ns2 = " << s2 << "\ns3 = " << s3 21 << "\n\nstrcmp(s1, s2) = " << setw( 2 ) << strcmp( s1, s2 ) 22 << "\nstrcmp(s1, s3) = " << setw( 2 ) << strcmp( s1, s3 ) 23 << "\nstrcmp(s3, s1) = " << setw( 2 ) << strcmp( s3, s1 ); cout << "\n\nstrncmp(s1, s3, 6) = " << setw( 2 ) 26 << strncmp( s1, s3, 6 ) << "\nstrncmp(s1, s3, 7) = " << setw( 2 ) 27 << strncmp( s1, s3, 7 ) << "\nstrncmp(s3, s1, 7) = " << setw( 2 ) 28 << strncmp( s3, s1, 7 ) << endl; 29 return 0; // indicates successful termination 30 } // end main

17 例題 :Comparing Strings with strcmp and strncmp s1 = Happy New Year s2 = Happy New Year s3 = Happy Holidays strcmp(s1, s2) = 0 strcmp(s1, s3) = 1 strcmp(s3, s1) = -1 strncmp(s1, s3, 6) = 0 strncmp(s1, s3, 7) = 1 strncmp(s3, s1, 7) = -1

18 例題 :Tokenizing a String with strtok 10 int main() 11 { 12 char sentence[] = "This is a sentence with 7 tokens"; 13 char *tokenptr; cout << "The string to be tokenized is:\n" << sentence 16 << "\n\nthe tokens are:\n\n"; // begin tokenization of sentence 19 tokenptr = strtok( sentence, " " ); // continue tokenizing sentence until tokenptr becomes NULL 22 while ( tokenptr!= NULL ) 23 { 24 cout << tokenptr << '\n'; 25 tokenptr = strtok( NULL, " " ); // get next token 26 } // end while 28 cout << "\nafter strtok, sentence = " << sentence << endl; 29 return 0; // indicates successful termination 30 } // end main

19 例題 : Tokenizing a String with strtok The string to be tokenized is: This is a sentence with 7 tokens The tokens are: This is a sentence with 7 tokens After strtok, sentence = This

20 C-string Arguments and Parameters 因為 c-string parameter 是陣列 C-strings 事宜 call by reference 的方式傳遞 其值可被呼叫函數的內部指令改變 如果想避免被修改, 可以 const 宣告函數引數 一般陣列需要把元素個數當作參數傳遞,C-strings 可有彈性 傳遞元素個素 不傳遞, 找出結束字元即可算出元素個數

21 Input/Output of Character Arrays 除了可用陣列方式搭配迴圈逐一元素輸出入 ( 勿忘加上結束字元 ) 外, 也可使用簡易輸出入 例如 : char st[5]; for (n=0;n<5;n++) { cout << st[n]; cin>>st[n]; } char str[10]= My god! ; char message[12]; cout << str; cin >> message; 使用字元陣列儲存字串時切勿覆蓋掉結束字元

22 String/Numeric Conversion Functions 須 #include <cstdlib> FUNCTION PARAMETER ACTION atoi C-string converts C-string to an int value, returns the value atol C-string converts C-string to a long value, returns the value atof C-string converts C-string to a double value, returns the value itoa int,c-string, int converts 1 st int parameter to a C-string, stores it in 2 nd parameter. 3 rd parameter is base of converted value

23 String/Numeric Conversion Functions int inum; long lnum; double dnum; char intchar[10]; inum = atoi("1234"); // puts 1234 in inum lnum = atol("5678"); // puts 5678 in lnum dnum = atof("35.7"); // puts 35.7 in dnum itoa(inum, intchar, 8); // puts the string // "2322" (base 8 for ) in intchar

24 String/Numeric Conversion Functions - Notes 如果 C-string 中含有非數字字元, 回傳結果就變成未定義 可能狀況一 : 以非數字字元前的數字字元作為回傳結果 可能狀況二 : 回傳 0 itoa 函數不做陣列長度檢查, 請自備足夠的長度空間來儲存回傳的字串

25 Output of C-strings cout 之直接輸出 : 字串之輸出 cout << message; cout.put() 之輸出 : 單一字元之輸出 cout.put(message[5]); cout.write() 之輸出 : 功用為輸出字串前 n 個字元, 並不因碰到字串之結束字元 \0 而結束 cout.write(message, 21);

26 Input of C-strings cin 之直接輸入 cin.getline() 之輸入 : 整行輸入或限定字數輸入 cin.get() 之輸入 : 逐字輸入或限定字數輸入

27 Direct C-string Input 使用 extraction operator >> 注意事項 Tab, space, line breaks 會被跳過 輸入讀取多個變數時會以空白和跳行作為分隔 字串變數須事先備好足夠的記憶體空間 (C++ 不會警告陣列長度不夠 ) char a[80], b[80]; cout << "Enter input: "; cin >> a >> b; cout << a << b << "END OF OUTPUT\n"; 結果 : Enter input: Do be do to you! DobeEND OF OUTPUT

28 C-string Input with getline() cin.getline() 讀資料時只有在輸入字串後遇到 Enter 鍵 ( \n ) 後才取得資料交給字串變數, 並捨去 \n 後在字串尾加上 \0 cin.getline(str,num_of_char); 如要以 getline 來輸入 20 個字元之字串 ( 第 21 個字元為結束字元 ), 就用 cin.getline(str,21); 此敘述會將整行字串放入 name 內, 但輸入字元需小於 20 如果在 20 各字元內遇到 \n, 則停止讀取 \n 的後續字元

29 C-string Input with get() cin.get() : int get(); // 讀取下一字元, 傳回整數型態 istream & get(char&); 讀取單一字元放入參數內 get() 可用來讀取 space, \n 等特殊字元 char c1, c2, c3, c4; cin.get(c1); cin.get(c2); cin.get(c3); cin.get(c4); cout<<c1<<c2<<c3; 結果 : istream & get(char*, int len, char = \n ); 讀取 (len-1) 個字元, 當中時若碰到輸入鍵 ( \n ) 就結束 ( \n 還留在 input stream 中 ) AB CD AB C

30 例題 : 以 get() 檢查輸入行的結束 cout << Enter a line of input:\n ; char symbol; do { cin.get(symbol); cout <<symbol; } while (symbol!= n ); cout << That s all.\n ;

31 例題 : 以 get() 參數輸入後輸出 #include <iostream> using namespace std; const int SIZE=21; int main( ){ int age; char sport[size]; cout << 輸入年齡 :"; cin<<age; cout <<" 喜好運動名 :"; cin.get(sport,size); cout << \n << age << 歲的你, 喜歡 輸入年齡 :18 喜好運動名 : 18 歲的你, 喜歡我也很喜歡 <<sport<<, 我也很喜歡 \n"; return 0; } Why 運動名 sport 無法輸入? 原因乃在讀取年齡後輸入鍵 (Enter)( \n ) 保留在 input stream 內, 因此下一輸入 cin.get(sport,20) 就讀到 \n ( 別忘了 get() 不會跳過 \n 和空格 ), 所以造成 sport 得到一 NULL 字元而已

32 解決 cin.get() 讀取資料時留住 \n 在輸入緩衝區之困擾 利用第一種格式無參數之 cin.get(); 在接下來讀取 \n, 因無參數之 get() 之功能乃讀取下一字元, 讓輸入緩衝區空無一物後, 下一輸入才能正常運作, 即 : cin.get(name,size); // 讀取 Bill Gates cin.get(); // 讀取 \n 或將上述兩列合併如下 : cin.get(name,size).get();

33 例題 : 數字輸入與 getline() 輸入 #include <iostream> //cout using namespace std; const int SIZE=21; int main( ){ char *sentence; short n; cout <<" 字串長度 ="; cin >> n; sentence = new char[n-1];// 配置記憶體 cout <<" 輸入字串 = ; cin.getline(sentence,n); cout <<" 輸入字串為 "<<sentence<<endl; delete sentence; // 釋放記憶體 return 0; } 字串長度 =30 輸入字串 = 輸入字串為 為何無法輸入字串呢?sentence= \0

34 More Member Functions putback() 退回上一個讀取字元到 input stream 中 ( 下次讀取會讀到此退回字元 ) cin.putback(lastchar); peek() 傳回下個字元, 但仍然讓該字元留在 input stream 中 peekchar = cin.peek(); ignore() 最多跳過指定個數的字元, 直到特定字元出現 cin.ignore(1000, \n ); Skips at most 1000 characters until \n

35 例題 : 輸入數字和文字的判斷 ( 版本一 ) cout << "Enter a number or a word: "; c = cin.get(); if ( (c >= '0') && (c <= '9') ) { cin.putback (c); cin >> n; cout << "You have entered number " << n << endl; } else { cin.putback (c); cin >> str; cout << " You have entered word " << str << endl; }

36 例題 : 輸入數字和文字的判斷 ( 版本二 ) cout << "Enter a number or a word: "; c=cin.peek(); if ( (c >= '0') && (c <= '9') ) { cin >> n; cout << "You have entered number " << n << endl; } else { cin >> str; cout << " You have entered word " << str << endl; }

37 String Manipulation Functions 須先 #include <cctype>

38 String Manipulation Functions 須先 #include <cctype>

39 String Manipulation Functions 須先 #include <cctype>

40 Standard Class string C++ 內建的字串物件類別 須 #include <string> 須 using namespace std; 可以視同一般的基本型態 ( 如 int, float, double, char 等 ) 使用 可以指定 (assign) 比較 (compare) 串接 (concatenation) : string s1, s2, s3; s3 = s1 + s2; //Concatenation If (s1==s2) s3 = "Hello Mom! ; //Assignment

41 例題 :string 的使用

42 I/O with Class string 與其他基本型態相同 string s1, s2; cin >> s1; cin >> s2; 結果 : User types in: May the hair on your toes grow long and curly s1 receives value "May" s2 receives value "the"

43 getline() with Class string 一個全域性函數, 輸入完畢後回傳一個 cin 物件的 reference 與 cin 的 getline() 使用相同 結果 : string line; cout << "Enter a line of input: "; getline(cin, line); cout << line << "END OF OUTPUT"; Enter a line of input: Do be do to you! Do be do to you!end OF INPUT

44 Other getline() Versions 可以指定分隔符號 string line; cout << "Enter input: "; getline(cin, line, "?"); 讀取輸入字元直到? 出現 getline() 函數回傳一個 cin 的 reference string s1, s2; getline(cin, s1) >> s2; 相當于 : (cin) >> s2;

45 Class string Processing 具備 c-strings 所有運算, 且還更多函數 ( 超過 100 個 )

46 Class string Processing

47 C-string and string Object Conversions 自動轉換 c-string 到 string object: char acstring[ ] = My C-string ; string stringvar; stringvar = acstring; // OK 不允許從 string 到 c-string acstring = stringvar; 必須使用 strcopy 進行 copy 運算 strcpy(acstring, stringvar.c_str());

新版 明解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言語入門編『索引』 !... 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

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2 第 六 讲 指 针 与 字 符 串 1 内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2 指 针 什 么 是 指 针 指 针 的 定 义 与 运 算 指 针 与 一 维 数 组 指 针 数 组 行 指 针 与 二 维 数 组 指 针 与 引 用 指 针 与 函 数 3 指 针 定 义 什 么 是 指 针 指 针 变 量, 简 称 指 针, 用 来 存 放

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

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

Microsoft PowerPoint - string_kruse [兼容模式]

Microsoft PowerPoint - string_kruse [兼容模式] Strings Strings in C not encapsulated Every C-string has type char *. Hence, a C-string references an address in memory, the first of a contiguous set of bytes that store the characters making up the string.

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

《计算概论》课程 第十九讲 C 程序设计语言应用

《计算概论》课程 第十九讲  C 程序设计语言应用 计算概论 A 程序设计部分 字符数组与字符串 李戈 北京大学信息科学技术学院软件研究所 lige@sei.pku.edu.cn 字符数组的定义 #include int main() char a[10] = 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' ; for (int i = 0; i < 10; i++) cout

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 - ch09_AEL0080.ppt

Microsoft PowerPoint - ch09_AEL0080.ppt 9 字 串 子曰 : 質勝文則野, 文勝質則史 文質彬彬, 然後君子 論語論語.雍也第六雍也第六 標準的 C++ 提供了方便的程式庫, 讓我們能將 字串 視為獨立的單元, 以進行各種存取和剪接的處理 1/36 字串 9.1 9.2 9.3 9.4 9.5 字串的基本概念字串的輸入與輸出字串的處理字串的指標陣列字串處理在編碼上的應用 2/36 字串的基本概念 字串 (string) 是由雙引號 所包括起來的一串文字

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

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 Word - AEL 序.doc

Microsoft Word - AEL 序.doc 序 C++ 全方位學習一書入選 100 狀元閱讀書單科學類排名第 15, 也是唯二入選的程式設計類書, 因此筆者決定重新改版, 以便造福更多想學習 C++ 程式設計的學生 C++ 全方位學習第二版保留第一版的編排特色, 而刪除比較不實用的大型程式範例與標準範本程式庫, 然後在各章習題中加入選擇題, 使其更加適合用於技職院校及大學教學 C++ 全方位學習第二版是針對專科與大學教學進度而編寫的, 內容由淺入深

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

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 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 Word - CPE考生使用手冊160524.docx

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

More information

FY.DOC

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

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 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/C++基礎程式設計班 C/C++ 基礎程式設計 C++: 物件的使用 參考 重載函式 成就別人認為不可能的事 Do what nobody else considered possible. -Steve Jobs 講師 : 張傑帆 CSIE NTU C++ 相較於 C 的特色 向下相容 在 C 語言中, 我們學了許多程式語法, 所有學過的東西, 在 C++ 中都可以使用 高階的程式描述方式 更利於用來開發大型專案, 讓程式設計師在分工時更能快速的開發程式,

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

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

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

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

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

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

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 範 例 試 題 (C++) 試 題 編 號 :11900-920201-4 審 定 日 期 : 94 年 7 月 1 日 修 訂 日 期 : 96 年 2 月 1 日 97 年 1 月 30 日 ( 第 二 部 份 ) 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 應 檢 參 考 資 料 壹 試

More information

Strings

Strings Polymorphism and Virtual Functions Cheng-Chin Chiang Virtual Function Basics 多 型 (Polymorphism) 賦 予 一 個 函 數 多 種 意 涵, 存 在 於 同 一 類 別 之 內 祖 先 類 別 與 後 代 類 別 間 物 件 導 向 程 式 設 計 基 本 原 理 虛 擬 函 數 (Virtual Function)

More information

C 語言—陣列及字串

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

More information

Fuzzy Highlight.ppt

Fuzzy Highlight.ppt Fuzzy Highlight high light Openfind O(kn) n k O(nm) m Knuth O(n) m Knuth Unix grep regular expression exact match Yahoo agrep fuzzy match Gais agrep Openfind gais exact match fuzzy match fuzzy match O(kn)

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

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

科学计算的语言-FORTRAN95

科学计算的语言-FORTRAN95 科 学 计 算 的 语 言 -FORTRAN95 目 录 第 一 篇 闲 话 第 1 章 目 的 是 计 算 第 2 章 FORTRAN95 如 何 描 述 计 算 第 3 章 FORTRAN 的 编 译 系 统 第 二 篇 计 算 的 叙 述 第 4 章 FORTRAN95 语 言 的 形 貌 第 5 章 准 备 数 据 第 6 章 构 造 数 据 第 7 章 声 明 数 据 第 8 章 构 造

More information

Microsoft Word - CH09

Microsoft Word - CH09 字串 子曰 : 質勝文則野, 文勝質則史 文質彬彬, 然後君子 論語.雍也第六 和 是資料的兩大基礎元素 固然可以視為由 字元 構成的一維陣列, 標準的 C++ 提供了方便的程式庫, 讓我們能將 字串 視為獨立的單元, 以進行各種存取和剪接的處理 本章將探討處理字串的相關技術 9.1 字串的基本概念 9.2 字串的輸入與輸出 9.3 字串的處理 9.4 字串的指標陣列 9.5 字串處理在編碼上的應用

More information

Strings

Strings Inheritance Cheng-Chin Chiang Relationships among Classes A 類 別 使 用 B 類 別 學 生 使 用 手 機 傳 遞 訊 息 公 司 使 用 金 庫 儲 存 重 要 文 件 人 類 使 用 交 通 工 具 旅 行 A 類 別 中 有 B 類 別 汽 車 有 輪 子 三 角 形 有 三 個 頂 點 電 腦 內 有 中 央 處 理 單 元 A

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

第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

Microsoft PowerPoint - 4. 数组和字符串Arrays and Strings.ppt [兼容模式]

Microsoft PowerPoint - 4. 数组和字符串Arrays and Strings.ppt [兼容模式] Arrays and Strings 存储同类型的多个元素 Store multi elements of the same type 数组 (array) 存储固定数目的同类型元素 如整型数组存储的是一组整数, 字符数组存储的是一组字符 数组的大小称为数组的尺度 (dimension). 定义格式 : type arrayname[dimension]; 如声明 4 个元素的整型数组 :intarr[4];

More information

学院信息第八期

学院信息第八期 石 景 山 区 业 余 大 学 暨 石 景 山 社 区 学 院 学 院 信 息 半 月 刊 每 月 15 日 30 日 下 发 2014 年 第 七 期 ( 总 第 166 期 ) 2014 年 5 月 30 日 本 期 要 目 党 的 群 众 路 线 教 育 实 践 活 动 1 区 领 导 深 入 业 余 大 学 调 研 征 求 意 见 建 议 参 观 廉 政 展 览 接 受 崇 廉 尚 廉 教

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

Scott Effective C++ C++ C++ Roger Orr OR/2 ISO C++ Effective Modern C++ C++ C++ Scoot 42 Bart Vandewoestyne C++ C++ Scott Effective Modern C++ Damien

Scott Effective C++ C++ C++ Roger Orr OR/2 ISO C++ Effective Modern C++ C++ C++ Scoot 42 Bart Vandewoestyne C++ C++ Scott Effective Modern C++ Damien Effective Modern C++ C++ C++ C++11/C++14 C++ Scott Meyers Gerhard Kreuzer Siemens AG Effective Modern C++ Effective Modern C++ Andrei Alexandrescu Facebook Modern C++ Design C++ C++ Nevin Liber DRW Trading

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

Microsoft Word - 11.doc

Microsoft Word - 11.doc 除 錯 技 巧 您 將 於 本 章 學 到 以 下 各 項 : 如 何 在 Visual C++ 2010 的 除 錯 工 具 控 制 下 執 行 程 式? 如 何 逐 步 地 執 行 程 式 的 敘 述? 如 何 監 看 或 改 變 程 式 中 的 變 數 值? 如 何 監 看 程 式 中 計 算 式 的 值? 何 謂 Call Stack? 何 謂 診 斷 器 (assertion)? 如 何

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

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

Microsoft Word - 0405

Microsoft Word - 0405 附 件 二 之 4 十 二 年 國 民 基 本 教 育 國 中 教 師 有 效 教 學 深 耕 推 廣 計 畫 優 良 教 案 甄 選 比 賽 教 學 計 畫 ( 教 案 ) 主 題 名 稱 問 路 / 方 向 指 示 教 學 節 數 5 節 教 材 來 源 改 編 教 科 書 ( 康 軒 翰 林 南 一 其 他 主 題 Book4 Unit9: How Do We Get to the Night

More information

Microsoft PowerPoint - Class4.pptx

Microsoft PowerPoint - Class4.pptx C++ 程式初探 IV 2015 暑期 ver. 1.0.2 C++ 程式 IV 大綱 1. 時間函式 2. 格式化輸出 3. 遞迴函式 (recursion) 4. 字串 5. 字串轉型 2 補充語法 時間計算 引入標頭檔 #include #include #include #include using namespace

More information

Microsoft Word - 01.DOC

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

More information

Microsoft Word - 970617cppFinalSolution.doc

Microsoft Word - 970617cppFinalSolution.doc 國 立 台 灣 海 洋 大 學 資 訊 工 程 系 C++ 程 式 設 計 期 末 考 參 考 答 案 姓 名 : 系 級 : 學 號 : 97/06/17 考 試 時 間 :10:00 12:10 試 題 敘 述 蠻 多 的, 看 清 楚 題 目 問 什 麼, 針 對 重 點 回 答 是 很 重 要 的 ; 不 確 定 的 請 一 定 要 當 場 提 出 來, 不 要 白 花 力 氣 在 誤 會

More information

!194 課程 大綱 陣列介紹 [P.195] 陣列的使 用 [1] - 多個同型變數 [P.196] 陣列的初始化 [P.198] 陣列的使 用 [2] - 循序存取 [P.199] 陣列的使 用 [3] - 隨機存取 [P.200] 陣列的複製 [P.203] 在函式間傳送陣列 [P.204]

!194 課程 大綱 陣列介紹 [P.195] 陣列的使 用 [1] - 多個同型變數 [P.196] 陣列的初始化 [P.198] 陣列的使 用 [2] - 循序存取 [P.199] 陣列的使 用 [3] - 隨機存取 [P.200] 陣列的複製 [P.203] 在函式間傳送陣列 [P.204] !193 第六講 陣列與字串 講師 : 李根逸 (Ken-Yi Lee), E-mail: feis.tw@gmail.com !194 課程 大綱 陣列介紹 [P.195] 陣列的使 用 [1] - 多個同型變數 [P.196] 陣列的初始化 [P.198] 陣列的使 用 [2] - 循序存取 [P.199] 陣列的使 用 [3] - 隨機存取 [P.200] 陣列的複製 [P.203] 在函式間傳送陣列

More information

程式基礎之字串函數與處理篇 前言 無論是在現實世界或是網路世界, 文字都是我們溝通的方式之一 在資訊的世界裡面, 怎麼利用程式把文字照自己想要的方式呈現就是個很基本也很重要的技術 但我們可能會發現, 許多文字處理要做的事情都很類似 ( 例如把兩個字串接在一起, 或是照特定格式輸出 ), 因此在 C

程式基礎之字串函數與處理篇 前言 無論是在現實世界或是網路世界, 文字都是我們溝通的方式之一 在資訊的世界裡面, 怎麼利用程式把文字照自己想要的方式呈現就是個很基本也很重要的技術 但我們可能會發現, 許多文字處理要做的事情都很類似 ( 例如把兩個字串接在一起, 或是照特定格式輸出 ), 因此在 C 程式基礎之字串函數與處理篇 前言 無論是在現實世界或是網路世界, 文字都是我們溝通的方式之一 在資訊的世界裡面, 怎麼利用程式把文字照自己想要的方式呈現就是個很基本也很重要的技術 但我們可能會發現, 許多文字處理要做的事情都很類似 ( 例如把兩個字串接在一起, 或是照特定格式輸出 ), 因此在 C 語言中提供了許多字串處理函數, 讓程式設計師能夠省去做相同處理的時間 而今天我們就是要來介紹這些函數,

More information

踏出C++的第一步

踏出C++的第一步 踏出 C++ 的第一步 講師 : 洪安 1 已經學會的 C 語言基本概念 基本資料型態 變數 基本輸入輸出 控制敘述 選擇控制 迴圈 陣列 函式 指標 字元與字串 結構 檔案處理 2 C v.s. C++ C 函數 程序式語言 Procedural language 結構化程式設計 Structured programming 演算法 Top-down C++ 類別 物件導向程式設計 Object-Oriented

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

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

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

More information

untitled

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

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

運算子多載 Operator Overloading

運算子多載 Operator Overloading 多型 Polymorphism 講師 : 洪安 1 多型 編譯時期多型 ( 靜態多型 ) function overloading 如何正確呼叫同名的函數? 利用參數個數與型態 operator overloading 其實同 function overloading 執行時期多型 ( 或動態多型 ) 如何正確呼叫不同物件的相同名稱的成員函數 利用繼承與多型 2 子類別與父類別物件間的指定 (assignment)

More information

Slide 1

Slide 1 Java 程式設計入門 講師 : 陳昭源 CSIE, NTU August 3, 2005 Outline Character & String Exercise August 3, 2005 Page 2 Character & String 處理字元資料時,Java 有三個類別可供使用 Character: 處理單一字元 String: 處理內容不改變 (immutable) 的字串 StringBuffer:

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

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

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

TF三段式

TF三段式 ICE - 4 - ICE TF - 1 - ICE - 2 - ICE - 3 - ICE - 8 - ICE - 5 - ICE - 6 - ICE - 7 - ICE - 12 - ICE - 9 - ICE - 10 - ICE - 11 - ICE - 16 - ICE - 13 - ICE - 14 - ICE - 15 - ICE - 20 - ICE - 17 - ICE - 18

More information

字元意義備註 \n 換行字元 \t Tab \r 迴車鍵 Windows 系統中以 \r\n 代表換行 \ 單引號 \" 雙引號 \0 空字元 用來代表字串的結束 \\ 倒斜線 倒斜線被用做跳脫字元, 因此要用兩個倒斜線表示 表 3.2: 常用特殊字元 ( 二 ) 常用技巧 : 字元判斷在 ASCI

字元意義備註 \n 換行字元 \t Tab \r 迴車鍵 Windows 系統中以 \r\n 代表換行 \ 單引號 \ 雙引號 \0 空字元 用來代表字串的結束 \\ 倒斜線 倒斜線被用做跳脫字元, 因此要用兩個倒斜線表示 表 3.2: 常用特殊字元 ( 二 ) 常用技巧 : 字元判斷在 ASCI 第三章 字串處理 第一節 字元與字串 一 字元與 ASCII C++ 中的字元 (Character) char 其實是儲存一個 0 到 255 的整數, 在電腦中有一個符號表, 每個符號都有他各自的編號 輸出字元時, 計算機就會自動將 char 裡面的整數去查符號表, 印出對應符號, 這個表格我們稱為 ASCII 碼 雖然 char 印出來是符號, 但實際上儲存的是整數 ASCII 碼網路上都能查到,

More information

untitled

untitled MODBUS 1 MODBUS...1 1...4 1.1...4 1.2...4 1.3...4 1.4... 2...5 2.1...5 2.2...5 3...6 3.1 OPENSERIAL...6 3.2 CLOSESERIAL...8 3.3 RDMULTIBIT...8 3.4 RDMULTIWORD...9 3.5 WRTONEBIT...11 3.6 WRTONEWORD...12

More information

ebook39-6

ebook39-6 6 first-in-first-out, FIFO L i n e a r L i s t 3-1 C h a i n 3-8 5. 5. 3 F I F O L I F O 5. 5. 6 5. 5. 6.1 [ ] q u e n e ( r e a r ) ( f r o n t 6-1a A 6-1b 6-1b D C D 6-1c a) b) c) 6-1 F I F O L I F ADT

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

VHDL(Statements) (Sequential Statement) (Concurrent Statement) VHDL (Architecture)VHDL (PROCESS)(Sub-program) 2

VHDL(Statements) (Sequential Statement) (Concurrent Statement) VHDL (Architecture)VHDL (PROCESS)(Sub-program) 2 VHDL (Statements) VHDL(Statements) (Sequential Statement) (Concurrent Statement) VHDL (Architecture)VHDL (PROCESS)(Sub-program) 2 (Assignment Statement) (Signal Assignment Statement) (Variable Assignment

More information

說 明 中 國 語 文 課 程 補 充 指 引 ( 非 華 語 學 生 ) 已 於 二 零 零 八 年 十 一 月 公 布, 並 於 十 二 月 連 同 各 種 配 套 教 學 參 考 資 料 派 發 學 校 我 們 建 議 有 收 取 非 華 語 學 生 的 學 校 採 用 補 充 指 引 考 慮

說 明 中 國 語 文 課 程 補 充 指 引 ( 非 華 語 學 生 ) 已 於 二 零 零 八 年 十 一 月 公 布, 並 於 十 二 月 連 同 各 種 配 套 教 學 參 考 資 料 派 發 學 校 我 們 建 議 有 收 取 非 華 語 學 生 的 學 校 採 用 補 充 指 引 考 慮 本 教 材 由 優 質 教 育 基 金 贊 助 地 利 亞 修 女 紀 念 學 校 ( 百 老 匯 ) 編 訂 現 經 教 育 局 課 程 發 展 處 調 適 整 理, 上 載 內 聯 網, 以 供 收 取 非 華 語 學 生 的 學 校 參 考 試 用 說 明 中 國 語 文 課 程 補 充 指 引 ( 非 華 語 學 生 ) 已 於 二 零 零 八 年 十 一 月 公 布, 並 於 十 二 月

More information

untitled

untitled ISBN 7115489041/Z 132 5.00 1 2 3 1 2 1 2 15 4 1 A B C 2 A B C 3 A B C 4 A B C 5 A B C 6 A B C A B C 1 2 3

More information

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM CHAPTER 6 SQL SQL SQL 6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM 3. 1986 10 ANSI SQL ANSI X3. 135-1986

More information

提问袁小兵:

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

More information

ebook14-4

ebook14-4 4 TINY LL(1) First F o l l o w t o p - d o w n 3 3. 3 backtracking parser predictive parser recursive-descent parsing L L ( 1 ) LL(1) parsing L L ( 1 ) L L ( 1 ) 1 L 2 L 1 L L ( k ) k L L ( 1 ) F i r s

More information

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Fortran Algol Pascal Modula-2 BCPL C Simula SmallTalk C++ Ada Java C# C Fortran 5.1 message A B 5.2 1 class Vehicle subclass Car object mycar public class Vehicle extends Object{ public int WheelNum

More information

epub 94-3

epub 94-3 3 A u t o C A D L AY E R L I N E T Y P E O S N A P S T Y L E X R E F - AutoLISP Object ARX A u t o C A D D C L A u t o C A D A u t o d e s k P D B D C L P D B D C L D C L 3.1 Wi n d o w s A u t o C A D

More information

Guide to Install SATA Hard Disks

Guide to Install SATA Hard Disks SATA RAID 1. SATA. 2 1.1 SATA. 2 1.2 SATA 2 2. RAID (RAID 0 / RAID 1 / JBOD).. 4 2.1 RAID. 4 2.2 RAID 5 2.3 RAID 0 6 2.4 RAID 1.. 10 2.5 JBOD.. 16 3. Windows 2000 / Windows XP 20 1. SATA 1.1 SATA Serial

More information

untitled

untitled 1 / ISBN 7702825476 2004 5 4.00 2 3 4 5 6 A 26 7 2 8 59 9 10 11 12 13 100 14 15 16 17 10 18 17 17 Cool Walkman Walkman 19 Bye 20 21 10 22 23 B 25 26 27 28 29 30 31 32 33 100 90 90 34 35 36 37 38 party

More information

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344>

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344> 1. 請 問 誰 提 出 積 體 電 路 (IC) 上 可 容 納 的 電 晶 體 數 目, 約 每 隔 24 個 月 (1975 年 更 改 為 18 個 月 ) 便 會 增 加 一 倍, 效 能 也 將 提 升 一 倍, 也 揭 示 了 資 訊 科 技 進 步 的 速 度? (A) 英 特 爾 (Intel) 公 司 創 始 人 戈 登. 摩 爾 (Gordon Moore) (B) 微 軟 (Microsoft)

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

Microsoft Word - ACL0204-ch11-ok.doc

Microsoft Word - ACL0204-ch11-ok.doc 第十一章 類別和動態記憶體配置 這章主要討論如何在類別中使用 new 和 delete 及如何處理動態記憶體所產生的一些問題, 主題似乎很少, 但這些主題會影響建構函數及解構函數的設計以及運算子的多型 先看一個特別的例子 若要產生一個類別, 其成員表示姓名, 最簡單的方法是用字元陣列儲存 但其缺點是字元陣列的長度該設多少呢? 若為 14 個字元的陣列, 遇到 Barthlomew Smeadsbury-Crafthovingham

More information

C++ 程序设计 OJ9 - 参考答案 MASTER 2019 年 6 月 7 日 1

C++ 程序设计 OJ9 - 参考答案 MASTER 2019 年 6 月 7 日 1 C++ 程序设计 OJ9 - 参考答案 MASTER 2019 年 6 月 7 日 1 1 CARDGAME 1 CardGame 题目描述 桌上有一叠牌, 从第一张牌 ( 即位于顶面的牌 ) 开始从上往下依次编号为 1~n 当至少还剩两张牌时进行以下操作 : 把第一张牌扔掉, 然后把新的第一张放到整叠牌的最后 请模拟这个过程, 依次输出每次扔掉的牌以及最后剩下的牌的编号 输入 输入正整数 n(n

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

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1 21 , 7, Windows,,,, : 010-62782989 13501256678 13801310933,,,, ;,, ( CIP) /,,. : ;, 2005. 11 ( 21 ) ISBN 7-81082 - 634-4... - : -. TP316-44 CIP ( 2005) 123583 : : : : 100084 : 010-62776969 : 100044 : 010-51686414

More information

10_String

10_String 字串 String 字串就是 String 物件, 因此, 宣告一個字串變數時會先指到一個 String 的參照, 再產生一個字串物件 String 類別定義的常用建構方法 Yung-Chen Chou 1 字串 String (Cont.) 字元陣列中索引碼為 3 的元素開始, 取出 4 個元素建構字串 由剛剛建立的字串 b 產生副本 雖然字串 d 和字串 b 的內容一樣, 但卻是不同的物件個體,

More information

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor 1 4.1.1.1 (Load) 14 1.1 1 4.1.1.2 (Save) 14 1.1.1 1 4.1.2 (Buffer) 16 1.1.2 1 4.1.3 (Device) 16 1.1.3 1 4.1.3.1 (Select Device) 16 2 4.1.3.2 (Device Info) 16 2.1 2 4.1.3.3 (Adapter) 17 2.1.1 CD-ROM 2 4.1.4

More information

软件测试(TA07)第一学期考试

软件测试(TA07)第一学期考试 一 判 断 题 ( 每 题 1 分, 正 确 的, 错 误 的,20 道 ) 1. 软 件 测 试 按 照 测 试 过 程 分 类 为 黑 盒 白 盒 测 试 ( ) 2. 在 设 计 测 试 用 例 时, 应 包 括 合 理 的 输 入 条 件 和 不 合 理 的 输 入 条 件 ( ) 3. 集 成 测 试 计 划 在 需 求 分 析 阶 段 末 提 交 ( ) 4. 单 元 测 试 属 于 动

More information

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 C C trio@seu.edu.cn C C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 Week3 C Week5 Week5 Memory & Pointer

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

PowerPoint Presentation

PowerPoint Presentation TOEFL Practice Online User Guide Revised September 2009 In This Guide General Tips for Using TOEFL Practice Online Directions for New Users Directions for Returning Users 2 General Tips To use TOEFL Practice

More information

個 人 的 手, 拉 著 瞎 子 的 手 把 他 帶 往 村 外 的 時 候, 對 於 瞎 子 來 講, 那 個 人 的 手 和 耶 穌 的 手 有 沒 有 區 別? 沒 有! 為 什 麼 沒 有 區 別? 因 為 對 於 一 個 瞎 子 來 說, 手 和 耳 朵 就 是 他 接 觸 世 界, 瞭

個 人 的 手, 拉 著 瞎 子 的 手 把 他 帶 往 村 外 的 時 候, 對 於 瞎 子 來 講, 那 個 人 的 手 和 耶 穌 的 手 有 沒 有 區 別? 沒 有! 為 什 麼 沒 有 區 別? 因 為 對 於 一 個 瞎 子 來 說, 手 和 耳 朵 就 是 他 接 觸 世 界, 瞭 課 目 : 講 道 法 學 生 : 楊 建 偉 老 師 : 汪 院 長 時 間 :2009 年 8 月 1 日 靈 命 三 階 ( 可 8:22-26) 在 四 部 福 音 書 中, 這 是 一 段 很 特 別 的 記 載 特 別 在 什 麼 地 方 呢? 是 不 是 特 別 在 耶 穌 基 督 對 一 個 病 人 的 醫 治? 不, 在 耶 穌 三 年 半 的 服 侍 當 中, 曾 經 醫 治 數

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

Microsoft PowerPoint - Bronson-v3-ch07.ppt [相容模式]

Microsoft PowerPoint - Bronson-v3-ch07.ppt [相容模式] C++ FOR ENGINEERS AND SCIENTISTS THIRD EDITION Chapter 7 Arrays Objectives 2 In this chapter, you will learn about: One-dimensional arrays 一維陣列 Array initialization 陣列起始化 Declaring and processing two-dimensional

More information

甄選入學howhow作印刷校過版

甄選入學howhow作印刷校過版 甄 選 入 學 How How 作 中 山 工 商 輔 導 處 編 著 ( 泰 宇 出 版 社 出 版 ) 1 過 去 國 內 的 教 育 幾 乎 是 以 聯 考 來 主 導 教 師 的 教 學 方 向, 此 種 一 元 化 的 入 學 方 式 讓 學 校 教 育 偏 重 智 育 的 發 展, 學 生 為 了 成 績 只 能 反 覆 的 過 度 的 練 習, 不 僅 降 低 學 生 的 學 習 興

More information

Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE "Project Properties" IDE makefile 1.

Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE Project Properties IDE makefile 1. Oracle Solaris Studio 12.2 IDE 2010 9 2 8 9 10 11 13 20 26 28 30 32 33 Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE "Project Properties" IDE makefile 1. "File" > "New

More information

四川省普通高等学校

四川省普通高等学校 四 川 省 普 通 高 等 学 校 计 算 机 应 用 知 识 和 能 力 等 级 考 试 考 试 大 纲 (2013 年 试 行 版 ) 四 川 省 教 育 厅 计 算 机 等 级 考 试 中 心 2013 年 1 月 目 录 一 级 考 试 大 纲 1 二 级 考 试 大 纲 6 程 序 设 计 公 共 基 础 知 识 6 BASIC 语 言 程 序 设 计 (Visual Basic) 9

More information

目 錄 壹 青 輔 會 結 案 附 件 貳 活 動 計 劃 書 參 執 行 內 容 一 教 學 內 容 二 與 當 地 教 師 教 學 交 流 三 服 務 執 行 進 度 肆 執 行 成 效 一 教 學 課 程 二 與 當 地 教 師 教 學 交 流 三 服 務 滿 意 度 調 查 伍 服 務 檢

目 錄 壹 青 輔 會 結 案 附 件 貳 活 動 計 劃 書 參 執 行 內 容 一 教 學 內 容 二 與 當 地 教 師 教 學 交 流 三 服 務 執 行 進 度 肆 執 行 成 效 一 教 學 課 程 二 與 當 地 教 師 教 學 交 流 三 服 務 滿 意 度 調 查 伍 服 務 檢 2 0 1 0 年 靜 宜 青 年 國 際 志 工 泰 北 服 務 成 果 報 告 指 導 單 位 : 行 政 院 青 年 輔 導 委 員 會 僑 務 委 員 會 主 辦 單 位 : 靜 宜 大 學 服 務 學 習 發 展 中 心 協 力 單 位 : 靜 宜 大 學 師 資 培 育 中 心 財 團 法 人 台 灣 明 愛 文 教 基 金 會 中 華 民 國 九 十 九 年 九 月 二 十 四 日 目

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

!"# $%& %!"# $%& %!"#$%& %! ( )***%% ) $)! +**+),,* -)+.* )( ) +, +*.*)+..**! )$,*)+$))$!"!#

!# $%& %!# $%& %!#$%& %! ( )***%% ) $)! +**+),,* -)+.* )( ) +, +*.*)+..**! )$,*)+$))$!!# !"#$%& % ( % )& (% ( % (( )( !"# $%& %!"# $%& %!"#$%& %! ( )***%% ) $)! +**+),,* -)+.* )( ) +, +*.*)+..**! )$,*)+$))$!"!# !"#$%& %!! "! # " $ # % & & ( ) *!+ !"#$%& % ( (*( (*+ "#$% $%%"# (*, (*% + +*(

More information

TX-NR3030_BAS_Cs_ indd

TX-NR3030_BAS_Cs_ indd TX-NR3030 http://www.onkyo.com/manual/txnr3030/adv/cs.html Cs 1 2 3 Speaker Cable 2 HDMI OUT HDMI IN HDMI OUT HDMI OUT HDMI OUT HDMI OUT 1 DIGITAL OPTICAL OUT AUDIO OUT TV 3 1 5 4 6 1 2 3 3 2 2 4 3 2 5

More information