Microsoft PowerPoint - ch03_AEL0080.ppt

Size: px
Start display at page:

Download "Microsoft PowerPoint - ch03_AEL0080.ppt"

Transcription

1 3 基本資料型態 能盡物之性, 則可以贊天地之化育 可以贊天地之化育, 則可以與天地矣 中庸中庸.第二十一章第二十一章 1/88 基本資料型態 整數和浮點數變數和常數算術運算標準數學函數的運算邏輯值及其運算字元與字串位元處理運算 2/88

2 C++ 的資料型態 C++ 資料型態 基本資料型態 整數 int, short, long 浮點數 float, double, 字元 long double char 邏輯值 bool 與位址相關的資料型態 指標參照 衍生資料型態 有結構的資料型態 string enum array struct union class 3/ 整數 整數 (integer values) 是所有不具小數點的數值 例如 : L 4/88

3 long int 8 進位整數 16 進位整數和 unsigned int ( 不加正負號的整數 ) 48U // unsigned int 75UL // unsigned long 372L // long 75l // long ( 不建議使用, 因為 l 和 1 不易區分 ) 012 // 128 = 10 0x12 // 1216 = 18 5/88 程式 Int.cpp // Int.cpp #include <iostream> using namespace std; int main() { cout << " 48U : " << 48U << endl; cout << " 75UL : " << 75UL << endl; cout << " 372L : " << 372L << endl; cout << " 75l : " << 75l << endl; cout << " 012 : " << 012 << endl; cout << " 0x12 : " << 0x12 << endl; return 0; 6/88 }

4 程式 Int.cpp 執行結果 48U : 48 75UL : L : l : : 10 0x12 : 18 7/88 浮點數 (floating point numbers) 帶有小數點的數值 浮點數的例子如下 : L f 3.7F 8/88

5 浮點數的指數表示法 (exponential notation) e 為 exponent 的縮寫, 可以寫為 E 或 e 9/88 float 和 long double 例如 : 4.7 // double 48.0F // float 48.0f // float 3.75L // long double 4.26e12 // double 4.26e+12L // long double (+ 號可以省略 ) 4.26E-12 // double 10/88

6 程式 Float.cpp // Float.cpp #include <iostream> using namespace std; // 主程式 int main() { cout << " 4.7 : " << 4.7 << endl; cout << " 48.0F : " << 48.0F << endl; cout << " 48.0f : " << 48.0f << endl; cout << " 3.75L : " << 3.75L << endl; cout << " 4.26e12 : " << 4.26e12 << endl; cout << " 4.26e+12L : " << 4.26e+12L << endl; cout << " 4.26E-12 : " << 4.26E-12 << endl; } 11/88 12/88 程式 Float.cpp 執行結果 4.7 : F : f : L : e12 : 4.26e e+12L : 4.26e E-12 : 4.26e-12

7 基本數值資料型態的實際適用範圍及有效位數 13/88 變數 (variables) 常數 (constants) 3.2 變數和常數 所有的變數和常數都需要經由宣告 (declaration) 才能取用 14/88

8 變數的宣告 賦予它一個名稱, 並指定其所屬的資料形態 例如 : Int Age; float Height; 上面這兩個敘述同時也完成了 Age 和 Height 兩個變數的定義 (definition) 15/88 變數的定義 在記憶體內確實配置足夠容納變數的記憶空間 對於變數和常數而言, 宣告通常也附帶完成了定義 16/88

9 宣告敘述與記憶體空間的對應關係 float a; FDFC 17/88 short 和 long 除了關鍵字 int 用來指定整數的資料型態外, short 和 long 分別用來代表 短的整數資料 和 長的整數資料 例如: long int Ia; long Ib; short int Ic; short Id; 18/88

10 float 和 double 單精確度的浮點數和雙精確度的浮點數分別以 float 和 double 這兩個關鍵字宣告 例如 : float Fa; // Fa 為單精確度的浮點數 double Db; // Db 為雙精確度的浮點數 19/88 20/88 程式 Average.cpp // Average.cpp #include <iostream> using namespace std; // 主程式 int main() { int Number = 3; float a, b; float c = 5.6; float Average; a = 7.8; b=3.9; Average = (a + b + c) / Number; cout << "a, b, c 的平均值是 : " << Average << endl; } 執行結果 a, b, c 的平均值是 :

11 多重宣告 (multiple declarations) float a, b; 相當於下列二式 : float a; float b; 21/88 變數 c 的宣告和初始化 float c = 5.6; 22/88

12 常數 (constant) 代號的用途 1. 避免重複直接寫出數值, 以減少輸入的錯誤 2. 可以只修改一處定義, 就能同時改變程式中所有使用這個值的地方 23/88 常數的例子 const double TaxRate = 0.17; const float Inch2Meter = 0.024; const int Max = 1024; 24/88

13 常數 一旦被宣告為常數, 則不能再是 lvalue ( 左值 ), 其內容不能更改 譬如 : const int Max = 1024; Max = 2048; // 錯誤! 常數不可以再給予新值 25/88 算術運算子 (arithmetic operators) 共有 7 個 : 26/88

14 表達式 (expression) 將常數 變數或函數以各種運算子聯結起來的組合 : x < 15.8 x = y + sin( z ) ( x + y ) * 0.8 z 27/88 敘述句 (statement) C++ 程式裡面最小的可執行單元 例如 : x = a + b * sin( c ) ; ; b++; y = ( b > 10.0 ) ; x = c ; 28/88

15 敘述句的規範 (1/2) 1. 以分號當結尾 2. 可以任意放置 例如 : x = a + b * ( c ) + c * ; 與 x = a + b * ( c ) + c * ; 29/88 敘述句的規範 (2/2) 3. 各個數值或變數名稱與運算子 (operator) 之間的空隔可有可無 例如 x=a+b; 與 x = a + b; 30/88

16 指派敘述 (assignment statement) 有等號的敘述 : Value = expression; 例如 : x = a + b; 指派敘述的處理步驟 (1) 算出 expression 的值 (2) 將此值放在 Value 裡面, 成為它的內容 31/88 運算元 (operand) 和運算子 (operator) 在 x * y 這個運算裡,x 和 y 稱為運算元 (operand), * 稱為運算子 (operator) 32/88

17 一元運算子 (unary operator) 和二元運算子 (binary operator) 作用於兩個運算元之間的運算子稱為二元運算子, 像 *, / 和 % 這類的運算子都是 如果只作用於一個運算元上, 則稱為一元運算子, 例如負號 33/88 運算符號 - - 既是一元運算子也是二元運算子 例如 -x 用來計算 x 的負值 然而 x y 卻是用來計算 x 和 y 的差值 我們將它視為兩個不同的運算子 34/88

18 算術運算的優先權和結合規則 與我們熟悉的 先乘除後加減 規則相吻合, 也就是說 : * 8 % 3 * 6-5 與 6 + ((4 * 8) % 3) * 6-5 的計算順序是一樣的 35/88 運算子的優先順序和結合關係 在同一個敘述內, 當運算子的優先權相同時, 則依照從左至右的順序處理 36/88

19 整數的除法 在 C++ 中, 整數相除時, 其餘數被直接捨棄 例如 1/2 得到 0 3/7 得到 0 15/2 得到 7 37/88 餘數運算子 (modulus operator) % 1%2 得到 1 3%7 得到 3 15%2 得到 1 38/88

20 累加運算子 (increment operator) 和累減運算子 (decrement operator) 表示式 N = N + 1 N = N - 1 M = M + 1 M = M 1 累加或累減表示式 N++ 或 ++N N-- 或 --N M++ 或 ++M M-- 或 --M 39/88 當 ++ 或 -- 寫在操作元之前 ( 稱為字首,prefix) 時 M = ++i; 相當於 i = i + 1; M = i; 40/88

21 當 ++ 或 -- 寫在操作元之後 ( 稱為字尾,postfix) 時 M = i++; 相當於 : M = i;i = i + 1; 41/88 累加和累減運算 M = i++ * 5; 相當於 M = i*5; i++; 而 M = ++i * 5; 則相當於 i++; M = i*5; 42/88

22 指派運算子 (assignment operators) 敘述 Num = Num + Inc; 具有相同計算結果的敘述 ( 使用指派操作子 ) Num += Inc; x = x * TaxRage; y = y / Ratio; x *= TaxRate; y /= Ratio; M = M % N; M %= N; 43/88 44/88 rvalue 和 lvalue 1. rvalue 和 lvalue 分別為 right value ( 右值 ) 和 left value ( 左值 ) 的縮寫 變數的值或表達式的計算結果稱為 rvalue, 因為它可以置於指派操作子等號 = 的右側 rvalue 本身不可以被指定數值 2. 經由 compiler 規劃過的記憶位置所儲存的內容稱為 lvalue, 因為它通常放在指派操作子的左側 它可以被指定存入某個數值 3. 指派敘述可以視為把 rvalue 置入 lvalue 的操作 例如, 下列兩個敘述 : 5 = x ; ( b = 10.0 ) = a ; 都是錯誤的敘述

23 45/88 資料型態間的轉換 - 程式 Convert.cpp // Convert.cpp #include <iostream> using namespace std; // 主程式 int main() { int a = 5; float x; x = a + 3.8; cout << "x 的值是 : " << x << endl; } 執行結果 x 的值是 : 8.8 隱性資料型態轉換 (implicit type conversions) 表示式 (expression) 計算結果的資料型態 a + 3.8f a float double 46/88

24 C++ 敘述的隱性資料型態轉換規則 1. 如果混合不同的資料型態, 則計算結果以最精確的資料型態為準 2. 當所有的運算元都具有相同的資料型態, 計算結果不做型態轉換 3. 如果是指派運算 (assignment operation), 則依 lvalue 的資料型態儲存 47/88 C++ 的兩種顯式資料型態轉換語法 ( 資料型態 ) 變數名稱 ; 資料型態 ( 變數名稱 ); 例如 x = float (a) + 3.8f ; 或是 x = (float) a + 3.8f ; 48/88

25 sizeof () 運算子 可以用來顯示資料所使用的記憶空間有幾個位元組 運算子 sizeof() 括號內的引數可以是資料, 也可以是資料型態 49/88 程式 Size.cpp 檢查資料型態的長度以及隱式資料轉換的效果 // Size.cpp #include <iostream> #include <conio> using namespace std; // 主程式 int main() { int a = 5; cout << " Size of int is : " << sizeof(int) << " bytes" << endl; cout << " Size of short is : " << sizeof(short) << " bytes" << endl; cout << " Size of(3.8f + a)is : " << sizeof(3.8f + a) << " bytes" << endl; return 0; } 50/88

26 程式 Size.cpp 執行結果 Size of int is : 4 bytes Size of short is : 2 bytes Size of (3.8f + a) is : 4 bytes 51/ 標準數學函數的運算 要使用 C++ 的數學函數前, 我們需要先知道 : 要呼叫的數學函數之名稱及其功能 該函數的輸入及輸出資料型態 如何將提供該函數的標頭檔 <cmath> 寫到程式裡 52/88

27 程式 Power3.cpp 計算實數 x 的 3 次方 // Power3.cpp #include <cmath> #include <iostream> using namespace std; // 主程式 int main() { double x ; cout << " 請輸入一個數值 :\n "; cin >> x; cout << " 它的 3 次方是 : " << pow(x,3) << endl ; return 0; } 53/88 程式 Power3.cpp 的操作過程 請輸入一個數值 : 4.8 它的 3 次方是 : /88

28 引數 (arguments) 及函數的重載 (Overloading) (x,3) x 3 pow() 55/88 使用內建的數學函式時最常犯的錯誤 -- 絕對值的使用 abs(x) 的結果是整數, 而 fabs(x) 才能獲得正確的浮點數 例如 : double x = ; cout << abs(x); // 得到 253 cout << fabs(x); // 得到 /88

29 x 常用的數學函數 57/ 邏輯值及其運算 邏輯值又稱為布林資料 (Boolean data), 只有 true 和 false 兩種值, 分別代表 真 和 偽 在 C++ 中, 任何不是 0 的值進行布林資料判斷的結果都視為 true 58/88

30 關係運算 (Relational Operations) 關係表達式 (relational expression): x < 3.8 的計算結果是 1 ( x 小於 3.8 ) 或 0 ( x 大於或小於 3.8 ) 59/88 常用的關係運算子 (relational operators ) 關係運算子 意義 範例 < 小於 x < 3.8 > 大於 x > 10.0 <= 小於或等於 4.8 <= y >= 大於或等於 c >= b == 相等 x == y!= 不相等 x!= y 60/88

31 C++ 邏輯運算子 (logical operators) 邏輯運算子 邏輯意涵 範例 && AND ( a > b ) && ( c > d ) OR ( x > 8.2 ) ( y < 0.0 )! NOT! ( x < 0.0 ) 61/88 關係運算子和邏輯運算子的運算優先順序 62/88 運算子 結合規則 相關的等值運算! ( 負號 ) 從右至左 -!a -(!a) * / % 從左至右 a*b/c ( a * b ) / c + - ( 減 ) 從左至右 a*b c ( a * b ) c < <= > >= 從左至右 a+b<c d (a+ b) < ( c d ) ==!= 從左至右 a<b == c d (a< b) == (c d) && 從左至右 a==b && c!=d (a == b )&&(c!=d ) 從左至右 a && b c (a && b) c = += -= /= 從右至左 a = b c a = (b c)

32 關係運算和邏輯運算 (1) a * b c < d (2) y = ( b > 10.0 ) ; 63/88 迪摩根定理 (De Morgan' s law) not (A and B) 等於 (not A) or (not B) not (A or B) 等於 (not A) and (not B) 以數學式表示 ( 和 分別為 OR 及 AND 的意思 ): ( A( A B ) B ) ( ( A ) A ) ( ( B B ) ) 64/88

33 迪摩根定理的應用實例!( x = a && y!= b && z!= c ) 可進一步改寫成 : ( x!= a y = b z = c) 65/88 bool 資料型態的應用實例 : 程式 BoolCheck.cpp 66/88 // BoolCheck.cpp #include <iostream> using namespace std; // 主程式 int main() { bool b1, b2, b3, b4; b1= true; b2= false; b3= (3>1); b4= (3<1); cout << "b1 = " << b1 << endl; cout << "b2 = " << b2 << endl; cout << "b3 = " << b3 << endl; cout << "b4 = " << b4 << endl; cout << "Size of bool is : " << sizeof(bool) << " byte" << endl; cout << "Size of b1 is : " << sizeof(b1) << " byte" << endl; return 0; }

34 程式 BoolCheck.cpp 執行結果 b1 = 1 b2 = 0 b3 = 1 b4 = 0 Size of bool is : 1 byte Size of b1 is : 1 byte 67/88 字元資料 1. 大寫與小寫英文字字母,A~Z,a~z 2. 十個阿拉伯數字 0~9 3. 特別符號, 如 + $ 等等 共 128 個符號 為了區別, 所有的字元都以單引號前後包起來 : 'a' 'A' '$' '+' '5' 68/88

35 字元 字元以 ASCII 碼儲存 每個字元佔一個位元組的大小 ASCII 是 American Standard Code for Information Interchange 的縮寫 例如 a 存成 b 存成 Q = 8110 = /88 字元的資料型態 char Ch = 'f' ; // 定義一個字元變數 ch 其內容存了字母 f cout << Ch << endl; 是字母 f 而不是 'f' // 輸出的 70/88

36 中文字的儲存 BIG-5 Unicode ( 通用碼 ), 亦採用 16 位元編碼, 能夠涵括世界上各種不同的文字和符號系統 71/88 逃離序列 (escape sequences) 代表無法用單一符號表示, 或是無法顯示的字元 反斜線 \ 則稱為逃離字元 (escape character) 如 : '\b' '\t' '\\' 72/88

37 常用的逃離序列 Escape Sequence code 意義 \n 跳到下一行 (newline) \t 跳到下一個定位點 (tab) \b 退回一格 (back) \f 跳到下一頁 (form feed) \r 輸入 (return) \\ 反斜線 \ \ 單引號 ' \ 雙引號 " \ 字串結束符號 73/88 字串 (string) 一序列用雙引號 " 包起來的字元 例如 : "c+b=" " 中文 " "The answer is: " "\ncorrect" "C:\\C++\\Examples\\File.cpp 在儲存的時候, 所有的字串後面都會被自動加上字元 '\0', 代表字串的結束 74/88

38 儲存字串的 byte 數目 "c+b=" // 使用 5 個位元組儲存 " 中文 " // 使用 5 個位元組儲存 "Good! " // 使用 6 個位元組儲存 "\nanswer: " // 使用 9 個位元組儲存 ( 每個中文字都以兩個 bytes 儲存 ) 75/88 "Good!" 儲存成 : 字串的儲存 G o o d! \0 1 byte 1 byte 1 byte 1 byte 1 byte 1 byte 76/88

39 " 中文 " 儲存成 : 字串的儲存 中文 \0 2 bytes 2 bytes 1 byte 77/88 驗證字串的儲存 // StringSize.cpp StringSize.cpp // 主程式 int main() { cout << " 字串 \"c+b=\" 的大小為 " << sizeof("c+b=") << " 位元組 " << endl; } 程式執行結果 : 字串 "c+b=" 的大小為 5 位元組 78/88

40 字元也可以進行運算 cout << 'a' + 0 << endl; // 答案為 97 cout << '0' + 0 << endl; // 答案為 48 cout << '\0' + 1 << endl; // 答案為 1 ('a' 的二進位儲存方式 所對應的值為 97 ) ( 字元 '0' 的值是 48, 而無法顯示的字元 '\0' 的值才是 0 ) 79/88 位元處理運算子 3.7 位元處理運算 位元處理運算子意義 ~ 補數 (complement) << 左移 >> 右移 & 且 (AND) ^ XOR 或 (OR) 80/88

41 位元處理運算子的真值表 位元處理運算子意義 ~ 補數 (complement) << 左移 >> 右移 & 且 (AND) ^ XOR 或 (OR) 81/88 位元處理運算子 AND 針對位元組的處理結果 AND 運算 表示式 計算結果 a b a & b /88

42 位元處理運算子 XOR 針對位元組的處理結果 XOR 運算 表示式 計算結果 a b a ^ b /88 位元處理運算子 OR 針對位元組的處理結果 OR 運算 表示式 計算結果 a b a b /88

43 位元處理運算子 ~ ( 補數運算 ) 針對位元組的處理結果 補數運算 表示式 計算結果 a ~a /88 右移運算針對位元組的處理結果 右移運算 表示式 計算結果 a a >> /88 如果有一個數值 X, 且 N 為整數, 則 X >> N; 會將 X 的所有位元往右移 N 個位元位置, 原來左端的位置則補上 0 如果原來的數值是正整數, 則右移一位元相當於除以 2 的運算, 左移一位元則相當於乘以 2

44 87/88 左移運算針對位元組的處理結果 左移運算 表示式 計算結果 a a << X << N; 會將 X 的所有位元往左移 N 個位元位置, 原來右端的位置則補上 0 如果原來的數值是正整數, 則左移一位元則相當於乘以 2 位元處理程式 BitOp.cpp // BitOp.cpp #include <iomanip> using namespace std; // 主程式 int main() { short Ia = 0x5678, Ib = 0x12ff; char C1 = 'A' ; cout << hex; cout << "Ia & Ib = ox" << (Ia & Ib) << endl; cout << "C1 >> 2 = ox" << (C1>>2) << endl; return 0; } 程式 BitOp.cpp 執行結果 : 88/88 Ia & Ib = ox1278 Ia ^ Ib = ox4487 C1 >> 2 = ox10

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

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

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

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

02

02 Thinking in C++: Volume One: Introduction to Standard C++, Second Edition & Volume Two: Practical Programming C++ C C++ C++ 3 3 C C class C++ C++ C++ C++ string vector 2.1 interpreter compiler 2.1.1 BASIC

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

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

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

Microsoft PowerPoint - ch04_AEL0080.ppt

Microsoft PowerPoint - ch04_AEL0080.ppt 4 選擇 在正常的情況下, 電腦程式的執行是以敘述的排列次序逐步處理的 使用控制架構 (control structures) 可以改變這種既定的先後次序, 讓程式得以進行更複雜的運算, 或以更簡潔的指令來實現演算法 1/42 選擇 4.1 演算法的描述方式 4.2 變數的運用範圍 (Scope of variables) 4.3 if- 敘述 4.4 巢狀 if- 敘述 (Nested if statements)

More information

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2 WWW PHP 2003 1 Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2 Comments PHP Shell Style: # C++ Style: // C Style: /* */ $value = $p * exp($r * $t); # $value

More information

Microsoft PowerPoint - 02_運算.pptx

Microsoft PowerPoint - 02_運算.pptx 回顧 第一個程式 基本架構 五行必寫的公式 註解的寫法 cout

More information

Microsoft Word - CS-981.doc

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

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

C/C++ - 函数

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

More information

C 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

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

元 [ 所 17-1-2-3] IA27 ( D ) 下 列 何 項 情 況, 其 夫 妻 所 得 可 免 合 併 申 報? (A) 當 年 度 結 婚 (B) 當 年 度 離 婚 (C) 妻 58 歲, 夫 62 歲 無 所 得 受 其 子 扶 養 (D) 以 上 皆 是 [ 所 17-1-1]

元 [ 所 17-1-2-3] IA27 ( D ) 下 列 何 項 情 況, 其 夫 妻 所 得 可 免 合 併 申 報? (A) 當 年 度 結 婚 (B) 當 年 度 離 婚 (C) 妻 58 歲, 夫 62 歲 無 所 得 受 其 子 扶 養 (D) 以 上 皆 是 [ 所 17-1-1] 綜 合 所 得 稅 選 擇 題 題 庫 IA01 ( A ) 非 中 華 民 國 境 內 居 住 之 個 人, 取 有 中 華 民 國 境 內 銀 行 給 付 之 活 期 儲 蓄 存 款 利 息 所 得, 依 據 所 得 稅 法 規 定, 應 否 課 徵 綜 合 所 得 稅? (A) 應 就 源 扣 繳 (B) 全 年 在 27 萬 元 以 下 免 納 所 得 稅 (C) 應 該 辦 理 結 算 申

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

Java 程式設計入門

Java 程式設計入門 Java 程式設計入門 講師 : 陳昭源 CISE, NTU August 28, 2005 Outline 變數 Variables 運算子 Operators 運算式 (Expressions) 敘述(Statements) & 程式區塊 (Blocks) 流程控制 Control Flow Statements if-else statements switch statements August

More information

PowerPoint Presentation

PowerPoint Presentation 第六章簡介運算子超載 (Operator Overloading) 6-1 運算子超載的基礎 6-2 超載二元運算子 6-3 超載邏輯與關係運算子 6-4 超載一元運算子 6-5 使用夥伴函數 6-6 細部檢視指定運算子 6-7 超載註標運算子 6-1 運算子超載的基礎 甚麼是運算子超載? 讓運算子 ( 符號 ) 有不同的意義 EX: 運算子的預設意義 ( 以 + 與 = 為例 ) class frac

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

FY.DOC

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

More information

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

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

More information

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

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

碩命題橫式

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

More information

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

Microsoft PowerPoint - ICP_02_Basic_Data_Type.ppt [相容模式] Introduction to Computer and Program Design Lesson 2 Basic Data Types James C.C. Cheng Department of Computer Science National Chiao Tung University The basic data types 變數 (variable) 是甚麼? 變數代表了一塊可以記錄資料的記憶體空間,

More information

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

C++ 程序设计 告别 OJ2 - 参考答案 MASTER 2019 年 5 月 3 日 1 C++ 程序设计 告别 OJ2 - 参考答案 MASTER 2019 年 5 月 3 日 1 1 TEMPLATE 1 Template 描述 使用模板函数求最大值 使用如下 main 函数对程序进行测试 int main() { double a, b; cin >> a >> b; cout c >> d; cout

More information

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

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

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

IO

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

More information

第 5 章 使用資料

第 5 章  使用資料 新觀念的 Visual Basic.NET 教本 第 5 章使用資料 5-1 資料的表示法 VB.NET 資料的分類 數值資料 字串資料 日期時間資料 布林資料 數值資料 整數 VB.NET 的整數與數學的整數並沒有什麼不同, 如 2005 0 +512-204 等均為正確的寫法, 但逗號是不能使用的, 如 10,000 便是不正確的表示法 十六進位數要在前面加上 &H, 八進位數要在前面加上 &O(

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

CHAPTER 1

CHAPTER 1 CHAPTER 1 1-1 System Development Life Cycle; SDLC SDLC Waterfall Model Shelly 1995 1. Preliminary Investigation 2. System Analysis 3. System Design 4. System Development 5. System Implementation and Evaluation

More information

840 提示 Excel - Excel -- Excel (=) Excel ch0.xlsx H5 =D5+E5+F5+G5 (=) = - Excel 00

840 提示 Excel - Excel -- Excel (=) Excel ch0.xlsx H5 =D5+E5+F5+G5 (=) = - Excel 00 Excel - - Excel - -4-5 840 提示 Excel - Excel -- Excel (=) Excel ch0.xlsx H5 =D5+E5+F5+G5 (=) = - Excel 00 ( 0 ) 智慧標籤 相關說明提示 -5 -- Excel 4 5 6 7 8 + - * / % ^ = < >= & 9 0 (:) (,) ( ) Chapter - :,

More information

Microsoft Word - Prog1-981.docx

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

More information

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

untitled

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

More information

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

C/C++ - 字符输入输出和字符确认 C/C++ 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

運算子多載 Operator Overloading

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

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

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

Microsoft PowerPoint - C-Ch11.ppt

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

More information

C 1

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

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc Java C++ Pascal C# C# if if if for while do while foreach while do while C# 3.1.1 ; 3-1 ischeck Test() While ischeck while static bool ischeck = true; public static void Test() while (ischeck) ; ischeck

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

数据结构与算法 - Python基础

数据结构与算法 - Python基础 Python 教材及课件 课件及作业见网址 xpzhang.me 1 1. Python 2. 3. (list) (tuple) 4. (dict) (set) 5. 6. 7. 2 Python Python 3 Python 4 Python 1, 100, -8080, 0,... 0x 0-9, a-f 0 xff00, 0 xa432bf 5 1.24, 3.14, -9.80,...

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 计算概论 A 课程程序设计部分 C++ 语言基本成分 数据成分 李戈 北京大学信息科学技术学院软件研究所 lige@sei.pku.edu.cn 再谈, 我们的进度安排 我们的学习过程 感性理性函数指针等 数据成分运算成分控制成分数组字符串 结构化的程序递归 传统学习过程 数据类型与表达式 输入输出 关系运算 控制语句 函数数组指针结构体 作业练习 感性认识作业练习 ( 以抄程序为主 ) 正常作业练习

More information

Microsoft Word - 09.數學136-281.docx

Microsoft Word - 09.數學136-281.docx 136. 計 算 梯 型 面 積 (1 分 ) 請 以 JAVA 運 算 式 計 算 下 面 梯 形 面 積, 並 輸 出 面 積 結 果 梯 形 面 積 公 式 為 :( 上 底 + 下 底 ) 高 2 每 一 組 依 序 分 別 輸 入 梯 形 的 上 底 下 底 及 高 的 整 數 輸 出 梯 形 面 積 輸 入 輸 出 94 190 120 99 54 47 137. 計 算 三 角 形 面

More information

Strings

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

新・解きながら学ぶJava

新・解きながら学ぶJava 481! 41, 74!= 40, 270 " 4 % 23, 25 %% 121 %c 425 %d 121 %o 121 %x 121 & 199 && 48 ' 81, 425 ( ) 14, 17 ( ) 128 ( ) 183 * 23 */ 3, 390 ++ 79 ++ 80 += 93 + 22 + 23 + 279 + 14 + 124 + 7, 148, 16 -- 79 --

More information

星星排列 _for loop Protected Sub Page_Load(ByVal sender As Object, ByVal e As Dim h As Integer = 7 'h 為變數 ' Dim i, j As Integer For i = 1 To h

星星排列 _for loop Protected Sub Page_Load(ByVal sender As Object, ByVal e As Dim h As Integer = 7 'h 為變數 ' Dim i, j As Integer For i = 1 To h 資訊系統與實習 製作 : 林郁君 一 2009.09.28 9X9 'button 被按下後 ' Dim i, j As Integer For i = 1 To 9 'i 從 1 到 9' For j = 1 To 9 'j 從 1 到 9' If j * i < 10 Then ' 如果 j 乘上 i 是為個位數 ' Response.Write(i & "*" & j & " =" & i *

More information

街街街街街街街街

街街街街街街街街 1 基本輸出入 與四則運算 本章大綱 5.1 本章的教學目標 5.2 Java 語言的運算子 5.3 算術與字串連接運算子 5.4 位元運算子 5.5 資料型態的轉換 5.1 本章的教學目標 程式語言有許多的算術運算所組成, 本章將介紹 Java 程式語言中基本輸出入運算子的功能與使用方式, 運算子包括 : 指定運算子 算數與字串連接運算子 位元運算子 資料型態的轉換運算子的功能與相關應用, 讓各位同學了解不同運算子的使用時機與應用方法

More information

Microsoft PowerPoint - ch11.ppt

Microsoft PowerPoint - ch11.ppt 11 前處理指令 前處理指令可以要求前處理器 (preprocessor) 在程式編譯之前, 先進行加入其它檔案的內容 文字取代以及選擇性編譯等工作 1/39 前處理指令 11.1 11.2 11.3 11.4 11.5 前處理器使用 #define 進行文字取代使用 #define 設定巨集指令條件式編譯其他與編譯器有關的前處理指令 2/39 3/39 前處理指令 #include 前處理指令不是

More information

untitled

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

More information

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

Microsoft PowerPoint - Bronson-v3-ch02.ppt [相容模式] C++ FOR ENGINEERS AND SCIENTISTS THIRD EDITION Chapter 2 Problem Solving Using C++ 1 Objectives 目標 2 In this chapter, you will learn about: Modular programs 模組化程式 Programming style 寫程式的風格 Data types 資料種類

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

Microsoft PowerPoint - 12 struct and other datatypes.ppt

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

More information

第1章

第1章 第 15 章 標準類別 1 本章提要 15.1 前言 15.2 基本資料類別介紹 15.3 Integer 類別 15.4 Double 類別 15.5 Float 類別 Long 類別 Short 類別 15.6 數學相關類別 Math 15.7 後記 2 15.1 前言 不同基本資料型別可以互相轉換, 但也只予許由小轉大的情況, 例如 1. byte 轉為 short int long float

More information

C/C++ - 数组与指针

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

More information

Microsoft Word - About_C_BitOperation.doc

Microsoft Word - About_C_BitOperation.doc (*) 位元的介紹位元 (binary digit: bit) 表示兩個值 :0 與 1 以一個 1 byte = 8 bits 為例, 一個位元可以表示兩個值 (0,1) ( 或者更廣義地說兩種狀態 ), 因此整個 byte ( 位元組 ) 的表示的範圍就是 2 8 =256 通常電腦在表示有正負號數值時會將最高位元 (msb: most significant bit 或最左位元 ) 當成符號位元,

More information

Microsoft PowerPoint - 8. 运算符重载 Operator Overloading.pptx

Microsoft PowerPoint - 8. 运算符重载 Operator Overloading.pptx 运算符重载 Operator Overloading class Point { public: ; double x_, y_; Why Operator Overloading? Point (double x =0, double y = 0):x_(x),y_(y) { int main(){ Point a(1., 2), b(3,4); Point c = a + b; return 0;

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

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F 1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET 2.0 2.0.NET Framework.NET Framework 2.0 ( 3).NET Framework 2.0.NET Framework ( System ) o o o o o o Boxing UnBoxing() o

More information

Microsoft PowerPoint - STU_EC_Ch02.ppt

Microsoft PowerPoint - STU_EC_Ch02.ppt 樹德科技大學資訊工程系 Chapter 2: Number Systems Operations and Codes Shi-Huang Chen Sept. 2010 1 Chapter Outline 2.1 Decimal Numbers 2.2 Binary Numbers 2.3 Decimal-to-Binary Conversion 2.4 Binary Arithmetic 2.5

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 PowerPoint - ch02_AEL0080.ppt

Microsoft PowerPoint - ch02_AEL0080.ppt 2 C++ 的基本語法和使用環境 親自撰寫和執行程式是學好程式語言的不二法門 本章藉由兩個簡單的程式, 介紹 C++ 程式的基本結構和開發環境, 讓初學者能逐漸建立使用 C++ 的信心 1/44 C++ 的基本語法和使用環境 2.1 2.2 2.3 2.4 2.5 2.6 基本程式開發步驟第一個完整的 C++ 程式 Borland C++ 編譯器的取得和安裝使用 Visual C++.NET 程式開發步驟第二個

More information

Microsoft Word - 1-1泰宇解答

Microsoft Word - 1-1泰宇解答 學校 : 學年度第學期第次段考科目名稱命題教師 : 年 班座號 : 姓名 : 得分 : 一 單選題 : ( ). 設 (x x6) (D) x Ax Bx Cx6, 則 A B C (A)6 (B) (C) 解答 :D ( ). 求 (x x x)( x x ) 的展開式中, x 項的係數為何? (A) (B) (C)6 解答 :A (D)7 9 統測 ( ). 下列何者為多項式? (A) x (B)

More information

Microsoft PowerPoint - STU_C_Lang_CH06.ppt

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

More information

!49 第 二講 資料型態 運算子與表示式 講師 : 李根逸 (Ken-Yi Lee),

!49 第 二講 資料型態 運算子與表示式 講師 : 李根逸 (Ken-Yi Lee), !49 第 二講 資料型態 運算子與表示式 講師 : 李根逸 (Ken-Yi Lee), E-mail: feis.tw@gmail.com !50 課程 大綱 資料型態 [P.51] C/C++ 內建的常 見資料型態 [P.52] 使 用 sizeof 看 大 小 [P.53] 變數宣告 [P.54] 不同資料型態間的差異 [P.55] 整數 (short int, int, long int)

More information

Microsoft Word - 970617cppFinalSolution.doc

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

More information

Computer Architecture

Computer Architecture ECE 3120 Computer Systems Assembly Programming Manjeera Jeedigunta http://blogs.cae.tntech.edu/msjeedigun21 Email: msjeedigun21@tntech.edu Tel: 931-372-6181, Prescott Hall 120 Prev: Basic computer concepts

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

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 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 - 把时间当作朋友(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

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

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

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

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

!##$!% "&! %( $#!##)!& $!##*!##*! "

!##$!% &! %( $#!##)!& $!##*!##*! "!! " " " " " " " " " " " " " " " " "!!!!!!!!!!!!!!!!!!!!!!!!!!!! " #!$% & &&% (!) &*% ( &++(!( &++* * ( )!+ #* #$ & # *, )!!!* &- &) #-! *, #,! " !##$!% "&! %( $#!##)!& $!##*!##*! " " 92 %, #$ %&#! 8$*2$*112

More information

LectureSlides1001 Data Storage.ppt [相容模式]

LectureSlides1001 Data Storage.ppt [相容模式] (continued) 1.6 Storing Integers 1.7 Storing Fractions 1.8 Data Compression 1.9 Communications Errors 1-3 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit

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

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

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

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

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

untitled

untitled Double Angel 1.,,,, [] (1),,,,,,,,,,,,,,,,() (),,( ), (2),,,,,1978 ( 53 )2 (M6.2) 6 (M7.4) 1997 ( 9 )3 1 (M6.2)5(M6.3),,,, (3),,1990,,, (4),,,,,,,,,,,,, 2.,,,,,, [] (1) 2 ,,,,, (2),,,,, (),,,,,,,,,, 10,,,,,,,,,,,,,,,,,,,,

More information

Microsoft Word - 01.DOC

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

More information

untitled

untitled ...1... 1...2... 2... 3... 4... 5...6... 6... 7... 8... 9...11...11... 12... 12...13... 13 ... 13... 14... 15... 16... 18... 19... 20... 20... 21... 22... 22... 23... 23...24... 24... 25... 25... 26...

More information

untitled

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

More information

untitled

untitled () () 1 1.01 1.02 1.03 01-02- 03-04- 05-06- 07-08- 09-1.04? 01-02- 2.01 2.02 01-02- 09-2.03 01-02- 03-09- 2.04 1 2.05 1 2.06 01-02- 03-04- 09-2.07 01-02- 03-04- 09-2.08 01-02- 03-04- 05-06- 07-08- 09-2.09

More information

Microsoft PowerPoint - ch02

Microsoft PowerPoint - ch02 02 數位資料表示法 CHAPTER 2-1 資料型態 2-2 二進位表示法 2-3 各種進位表示法的轉換 2-4 整數表示法 2-5 浮點數表示法 2-6 ASCII 及 Unicode 0 與 1 的組合 計算機概論 2 數位資訊的單位 位元 (binary digit, 簡稱 bit) 是數位資訊的基本粒子, 也是電腦儲存或傳遞資料的最小單位, 常用 0 或 1 來表示 當初電腦會採用位元表示資料,

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