Microsoft PowerPoint - ch12.ppt

Size: px
Start display at page:

Download "Microsoft PowerPoint - ch12.ppt"

Transcription

1 12 資料流與檔案的存取 如果程式所處理的資料只能寫在原始程式內部, 或以互動的方式由鍵盤逐一輸入, 則功能將很有限 本章探討如何從檔案讀取資料, 以及將處理後的資料存入檔案的方法 1/69 資料流與檔案的存取 資料流檔案的存取檔案的存取模式資料的讀取與寫入檔案內容的位置標記將檔案的存取寫成函數 2/69

2 3/69 資料流 (stream) 回顧標準的輸出入管道 cout 和 cin: 範例程式檔案 BasicIO.cpp // BasicIO.cpp #include <iostream> using namespace std; int main () int N; cout << 請輸入一個整數 : << endl; cin >> N; cout << 您輸入的是 << N << endl; return 0; 操作結果 請輸入一個整數 : 4563 您輸入的是 /69

3 資料流 (stream) 和資料流物件 (stream object) cout 是聯結程式和顯示器的管道, 而 cin 是聯結程式和鍵盤的管道 單向的資料流通管道為資料流 (stream) cin 是一個輸入資料流物件 (input stream object) cout 是一個輸出資料流物件 (output stream object) 5/69 物件 (object) 和類別 (class) 物件 (object), 其原文有 個體 對象 等多種意涵 類別是一種廣義的資料型態, 它可以由程式寫作者自行定義 由類別定義的 物件 不僅包括資料, 而且還包括與物件進行互動所需要的各種函數 cin 和 cout 分別屬於 istream 和 ostream 兩個類別 我們不需要定義 cin 和 cout, 因為它們是最常用的預設物件 6/69

4 驅動程式 驅動程式 (drivers) 是作業系統 ( 例如 Windows 和 Linux) 的一部份, 用來與硬體 ( 譬如鍵盤和顯示器 ) 溝通, 以處理硬體裝置與記憶體之間的資料記憶體流動 如下圖所示 : C++ 程式 cout cin Buffer Buffer 顯示器 鍵盤 7/69 資料流 (stream) 與硬體之間的關係圖 使用成員函數 (member functions) 的語法 類別 (Class) 內部所定義的各種函數稱為成員函數 (member functions) 或方法 (methods) 敘述 cin.get(ch); 裏, 句點. 稱為成員運算符號 (member operator), 它的前面是物件的名稱, 而其後是成員函數的名稱 8/69

5 呼叫物件 cin 的成員函數 get() cin.get (Ch); 成員函數 物件名稱 引數 9/69 檔案 在一個名稱之下, 內含有資料的獨立儲存單位 檔案通常儲存於硬碟 磁片 光碟 磁帶或 MO 等媒體上 10/69

6 11/69 檔案的存取 1. 程式開頭要加入標頭檔 : <fstream>, 以含入必要的類別宣告 2. 必需明確地宣告和定義讀寫檔案所需的管道 ( 亦即資料流 ) 例如 : 要讀取檔案時, 定義類別為 ifstream 的輸入型檔案資料流 : ifstream FileInput; 要寫入檔案時, 則需定義類別為 ofstream 的輸出型檔案資料流 : ofstream FileOutput; 讀寫檔案前, 需要先執行將檔案 開啟 (open) 的動作 讀寫完畢後, 最好執行將檔案 關閉 (close) 的動作 檔案和程式 資料流之間的關係 記憶體 驅動程式 暫存器 (register) 輸入檔案資料流 輸出檔案資料流 C++ 程式 儲存裝置 12/69

7 資料存取的語法 一旦檔案被開啟, 則資料存取的語法和先前 cin cout 的用法相同 例如 : FileInput >> x; FileOutput << x << endl 程式內部所直接使用的是各個 已經聯結到特定檔案的檔案資料流, 而不再提及檔案的名稱 13/69 將資料流聯結到檔案的語法 例如, 在檔案開啟時將敘述寫成 : FileInput.open( FileA.txt ); 檔案關閉時, 則不用再寫出檔案名稱, 只需寫成 : FileInput.close(); 14/69

8 範例程式 TaxFile.cpp 從檔案 Income.txt 將收入的數值讀到變數 Income 裏, 再呼叫函數 CalculateTax() 以計算稅額 Tax, 最後把稅額的數值輸出到顯示器, 並同時存到檔案 Tax.txt 裏 示範了如何宣告資料流, 如何開啟和關閉檔案, 以及如何在檔案裏存取資料的細節 15/69 範例程式 檔案 TaxFile.cpp // TaxFile.cpp #include <iostream> #include <fstream> using namespace std; double CalculateTax(double); // 函數的宣告 // --- 主程式 int main() char* FileNameIn = "Income.txt"; // 以字串的方式宣告檔名 char* FileNameOut = "Tax.txt"; double Income, Tax; ifstream FileInput; ofstream FileOutput; FileInput.open ( FileNameIn ); FileOutput.open( FileNameOut ); 16/69

9 17/69 if (!FileInput) cout << " 檔案 : " << FileNameIn << " 開啟失敗!" << endl; exit(1); if (!FileOutput) cout << " 檔案 : " << FileNameOut << " 存檔失敗!" << endl; exit(1); FileInput >> Income; Tax = CalculateTax(Income); cout << " 您要繳的綜合所得稅是 : " << Tax << " 元 "; 18/69 FileOutput << " 您要繳的綜合所得稅是 : " << Tax << " 元 "; FileInput.close(); // 關閉輸入檔案 FileOutput.close(); // 關閉輸出檔案 return 0; // --- 函數 CalculateTax() 的定義 // 改寫自 4.4 節 巢狀 if-else 敘述 // 程式 Tax.cpp 以計算稅額 double CalculateTax(double GIncome) double Tax; if (GIncome < 0.0) cout << " 您輸入的綜合所得淨額沒有意義!\n"; else if (GIncome < ) Tax = GIncome * 0.06;

10 else if (GIncome < ) Tax = GIncome * ; else if (GIncome < ) Tax = GIncome * ; else if (GIncome < ) Tax = GIncome * ; else Tax = GIncome * ; return Tax; 19/69 操作結果 您要繳的綜合所得稅是 : 元 20/69

11 檔案的存取模式 1.create ( 創造 ) 和 replace ( 取代 ): 如果檔案不存在, 要不要產生一個新的檔案, 如果檔案已經存在, 要不要將其取代 2.append ( 附加 ) 和 replace ( 取代 ): 從資料流輸入的資料要接在原來的內容之後, 還是要取代原來的內容 21/69 另外一種檢查開檔動作有沒有失敗的語法 將開檔部份的敘述改寫如下 : 22/69 FileInput.open (FileNameIn, ios::nocreate); if (FileInput.fail()) cout << " 檔案 : " << FileNameIn << " 開啟失敗!" << endl; exit(1);

12 結合資料流的宣告敘述和開檔的動作 如果檔案資料流 FileInput 在程式中只跟一個檔案聯結, 則可以進一步寫成 : ifstream FileInput (FileName, ios::nocreate); 參數 nocreate 又稱為模式指示參數 (mode indicator) 23/69 常用的模式指示參數 (mode indicator) 模式指示參數 ios::in ios::out ios::app ios::ate ios::binary ios::trunc ios::nocreate ios::noreplace 開檔模式將檔案開啟成輸入模式 將檔案開啟成輸出模式, 如果已有同名舊檔則將其取代 開啟為 append( 添加 ) 模式 移到所開啟檔案的結尾處 將開啟的檔案內容視為二進位碼 ( 預設模式為 文字 ) 如果檔案已經存在, 則將其內容清除 只用來開啟舊檔作為輸出之用, 如果檔案不存在就放棄 只用來開啟新檔作為輸出之用, 如果已有舊檔就放棄 24/69

13 統一使用 fstream 類別其後區別該資料流的方向 fstream FileInput; fstream FileOutPut; FileInput.open(FileName, ios::in); FileOutput.open(FileName, ios::out); 25/69 結合模式指示參數 進一步決定 如果要開啟以供輸入的檔案不存在 的處理方式, 使用 或 ( 也就是 or) 的語法 : FileInput.open(FileName, ios::in ios::nocreate); 26/69

14 EOF (end-of-file) 檔案的結束記號 EOF 為標頭檔 <fstream> 內定義的常數 它在 Windows 和 DOS 作業系統都是使用第 26 個 ASCII 字元 Ctrl-Z, 在某些作業系統內 EOF 的值設為 1 27/69 範例程式 ConvFile.cpp 使用本節介紹的語法進行讀檔與存檔的操作 首先從檔案 Original.txt 逐一讀進字母, 再經 <cctype> 中的函數 toupper() 將字母轉換為大寫字母後, 逐一存進檔案 Converted.txt 中 28/69

15 範例程式 檔案 ConvFile.cpp // ConvFile.cpp #include <iomanip> #include <iostream> #include <fstream> #include <cctype> using namespace std; char* FileNameIn = "Original.txt"; char* FileNameOut = "Converted.txt"; // --- 函數 Sort() 的宣告 ---- int Sort(char X); // --- 主程式 int main() 29/69 30/69 char C; fstream FileInput(FileNameIn, ios::in); if (!FileInput) cout << " 檔案 : " << " 開啟失敗!" << endl; exit(1); << FileNameIn fstream FileOutput(FileNameOut, ios::out); if (!FileOutput) cout << " 檔案 : << " 存檔失敗!" << endl; exit(1); << FileNameOut

16 31/69 while ((C = FileInput.get())!= EOF) switch (Sort(C)) case 1: FileOutput << char(toupper(c)); break; case 0: case 2: case 3: case 4: FileOutput << C ; break; case 5: FileOutput << "Other" << endl; break; default: cout << " 程式有問題!" << endl; FileOutput.close(); FileInput.close(); cout << " 成功存於檔案 " << FileNameOut << " 內.\n"; return 0; // --- 函數 Sort() 的定義 int Sort(char X) if (isupper(x)) return 0; else if (islower(x)) return 1; 32/69

17 else if (isdigit(x)) return 2; else if (isspace(x)) return 3; else if (ispunct(x)) return 4; else return 5; 33/69 操作結果 ( 在顯示器上會看到下列訊息 :) 成功存於檔案 Conerted.txt 內. 檔案 Original.txt 的內容是 : I love you, certainly. 檔案 Converted.txt 的內容是 : I LOVE YOU, CERTAINLY. 34/69

18 檔案資料流 fstream 的成員函數 成員函數名稱 get(ch) 表 12.4 fstream 的成員函數 用途從輸入資料流讀取一個字元 35/69 getline(s1,n, \n ) peek() put(ch) putback(ch) eof() ignore(n) 從輸入資料流讀取字元, 並將其依序置於字串 S1 中, 直到已讀取 (N-1) 個字元, 或遇到字元 \n 從輸入資料流中檢查下一個字元, 但不將其從資料流中取出 將一個字元置於輸出資料流中 在不影響檔案內容的情況下, 對輸入資料流放回一個字元 如果讀取的動作超過 EOF(end-of-file, 檔案結尾 ) 則函數值為 true 跳過下面 N 個字元 如果不寫參數, 而寫成 ignore(), 表示跳過下個字元 範例程式 RWFiles.cpp 從檔案 Record.txt 將字串資料和數值資料分別讀到字串陣列 Name 和數值陣列 Score 裏, 再單獨對 Score 進行計算, 最後把字串和數值存到檔案 Saved.txt 裏 這個程式示範輸入資料流的成員函數 peek() 的使用細節, 它用來檢查即將讀入的字元是否為 EOF 36/69

19 範例程式 檔案 RWFiles.cpp // RWFiles.cpp #include <iostream> #include <iomanip> #include <fstream> using namespace std; char* FileNameIn = "Record.txt"; char* FileNameOut = "Saved.txt"; // --- 主程式 int main() const int MaxNum = 40; const int MaxSize = 20; char Name [MaxNum][MaxSize]; int Score[MaxNum]; 37/69 fstream FileInput(FileNameIn, ios::in); if (!FileInput) cout << " 檔案 : " << FileNameIn << " 開啟失敗!" << endl; exit(1); fstream FileOutput(FileNameOut, ios::out); if (!FileOutput) cout << " 檔案 : " << FileNameOut << " 存檔失敗!" << endl; exit(1); int Count=0; while (FileInput.peek()!= EOF && (Count < MaxNum)) FileInput >> Name[Count] >> Score[Count]; Count++; 38/69

20 for (int i=0; i< Count; i++) Score[i] = Score[i]*0.8+20; FileOutput << '(' << i+1 << ')' << setw(12) << Name[i] << " " << setw(5) << Score[i] << endl; FileOutput.close(); FileInput.close(); cout << " 成功存於檔案 " << FileNameOut << " 內." << endl; return 0; 39/69 操作結果 ( 在顯示器上會看到下列訊息 :) 成功存於檔案 Saved.txt 內. 40/69 檔案 Record.txt 的內容是 : 王能治 87 李大為 92 蕭飛雪 78 張心怡 86 檔案 Saved.txt 的內容是 : (1) 王能治 89 (2) 李大為 93 (3) 蕭飛雪 82 (4) 張心怡 88

21 檔案內容的位置標記 (File Position Marker) 位置標記使用 相對位置 的觀念 : 從某個位置當起點, 再加上偏移量 (offset) 以到達所要的位置 按照起點位置的不同, 位置標記在使用上有下列三種模式 (modes of the file position marker): ios::beg 從檔案的開頭算起 (beg 為 begin 的縮寫 ) ios::cur 從目前位置算起 (cur 為 current 的縮寫 ) ios::end 從檔案結尾算起 (end 為結尾的意思 ) 41/69 配合檔案內容的位置標記的成員函數 表 配合檔案內容的位置標記的成員函數 成員函數 功 能 seekg( 偏移量, 模式 ) seekp( 偏移量, 模式 ) tellg() tellp() 在輸入檔案中, 將位置標記依模式所規定的起點, 移到偏移量所定的位置 在輸出檔案中, 將位置標記依模式所規定的起點, 移到偏移量所定的位置 從輸入檔案中, 獲得位置標記目前所在的位置 從輸出檔案中, 獲得位置標記目前所在的位置 位置標記 以及 偏移量 的資料型態必需是長整數 (long int) 各成員函數名稱中的 g 是 get ( 取得 ), 而 p 是 put ( 放入 ) 的簡寫 42/69

22 位置標記的成員函數舉例 1. FileOutput.seekp(5L, ios::cur); : 將位置標記在輸出檔案中從目前的位置往前移動 5 個字元的距離 2. FileOutput.seekp(2L, ios::beg); : 將位置標記在輸出檔案中移到第 3 個字元的位置 3. FileOutput.seekp(-5L, ios::end); : 將位置標記在輸出檔案中移到倒數第 5 個字元的位置 4. FileInput.seekg(0L, ios::beg); : 將位置標記移到輸入檔案開頭的位置 5. FileInput.seekg(0L, ios::end); : 將位置標記移到輸入檔案結尾的位置 43/69 使用成員函數 tellg() 從檔案資料流中獲得已開啟檔案中的字元數目 例如 : ifstream FileInput ( Data.txt ); Data.txt // 開啟檔案 long CharNum; FileInput.seekg(0L, ios::end); CharNum = FileInput.tellg(); // 移到檔案結束的地方 // 獲得字元數目 就可以得到 Data.txt 中的字元數目, 並將它儲存在長整數 CharNum 中 44/69

23 使用 seekg() 以移動位置標記在已開啟的檔案中游走 把位置標記先移到檔案結尾處, 再逐一往前移動, 把既有檔案中的字元次序顛倒過來 : 45/69 long Offset; char Ch; for (Offset=1L; Offset<= CharNum; Offset++) FileInput.seekg(-Offset, ios::end); Ch = FileInput.get(); FileOutput << Ch; 範例程式 FileReverse.cpp 我們將上述倒轉檔案內容的指令寫成完整的範例程式 這個程式首先從檔案 Original.txt 讀取資料, 將檔案中的字元次序顛倒過來後, 逐一存於檔案 Reversed.txt 中 46/69

24 範例程式 檔案 FileReverse.cpp 47/69 // FileReverse.cpp #include <iostream> #include <iomanip> #include <fstream> using namespace std; char* FileNameIn = "Original.txt"; char* FileNameOut = "Reversed.txt"; // --- 主程式 int main() long CharNum, Offset; char Ch; fstream FileInput(FileNameIn, ios::in); if (!FileInput) cout << 檔案 << FileNameIn << " 開啟失敗!" << endl; exit(1); fstream FileOutput(FileNameOut, ios::out); 48/69 if (!FileOutput) cout << 檔案 cout << FileNameOut << " 存檔失敗!" << endl; exit(1); << 檔案 << FileNameIn << " 開啟成功 " << endl; FileInput.seekg(0L, ios::end); // 移到檔案結束的地方

25 CharNum = FileInput.tellg(); // 獲得字元數目 for (Offset=1L; Offset<= CharNum; Offset++) FileInput.seekg(-Offset, ios::end); Ch = FileInput.get(); FileOutput << Ch; FileOutput.close(); FileOutput // 關閉 FileInput.close(); FileInput // 關閉 cout << " 倒轉檔案 " << FileNameIn << " 後的內容 \n 成功存於檔案 " << FileNameOut << " 內." << endl; return 0; 49/69 50/69 範例程式 FileAccess.cpp WriteString(): 使用檔案以儲存字串的函數 WriteData(): 使用檔案以儲存數字的函數 以字串為參數傳遞檔案名稱, 參數 Mode 則是模式指示參數 (mode indicator), 當 Mode 為 1 時是 append ( 附加 ),Mode 為 0 時是 replace ( 取代 )

26 範例程式 FileAccess.cpp: 函數 Add_Txt() 在字串後面附加.txt 延伸檔名 這個函數可以自動偵測做為檔案名稱的字串有沒有延伸檔名, 並加以修正 這個函數使用了 <cstring> 裹面宣告的函數 strcpy() 51/69 範例程式 檔案 FileAccess.cpp // FileAccess.cpp #include <iostream> #include <iomanip> #include <fstream> using namespace std; // --- 函數的宣告 void Add_Txt(char *); void WriteString (char *, char *, int Mode); // Mode:(1 = append, 0 = replace) void WriteData (char *, float *, int, int Mode); // --- 主程式 int main () 52/69

27 const DataSize = 12; float Data [DataSize]; char FileName[20] = "SaveRecord"; char* S1 = "A long time ago..."; Add_Txt(FileName); for (int i = 0; i < DataSize; i++) Data[i]= 3.8/float(1+i); WriteString(FileName, S1, 0); WriteData(FileName, Data, DataSize, 1); return 0; 53/69 // --- 函數 Add_Txt() 的定義 void Add_Txt(char *Fname) int i = 0; while ((Fname[i]!= 0) && (Fname[i]!= '.')) i++; strcpy(fname+i,".txt"); 54/69

28 // --- 函數 WriteString () 的定義 void WriteString (char *FileNameOut, char *String, int Mode) ofstream FileOutput; if (Mode) FileOutput.open( FileNameOut, ios::app); else FileOutput.open( FileNameOut, ios::out); if (!FileOutput) cout << " 檔案 : " << FileNameOut << " 存檔失敗!" << endl; exit(1); 55/69 FileOutput << String; FileOutput.close(); cout << " 成功存於檔案 " << " 內." << endl; << FileNameOut // --- 函數 WriteData () 的定義 void WriteData (char *FileNameOut, float *Data, int Size, int Mode) ofstream FileOutput; if (Mode) FileOutput.open( FileNameOut, ios::app); else FileOutput.open( FileNameOut, ios::out); if (!FileOutput) cout << " 檔案 : " << FileNameOut << " 存檔失敗!" << endl; exit(1); FileOutput << "\n 以下共有 " << Size << " 組數據 :\n"; 56/69 for (int i = 0; i<size; i++) FileOutput << Data[i] << endl; FileOutput.close(); cout << " 成功存於檔案 " << FileNameOut << " 內."<< endl;

29 操作結果 ( 在顯示器上會看到下列訊息 ) 成功存於檔案 SaveRecord.txt 內. 成功存於檔案 SaveRecord.txt 內. 檔案 Record.txt 的內容是 : A long time ago... 以下共有 12 組數據 : / /69 範例程式 Encoding.cpp 和 Decoding.cpp 改寫 9.5 節程式 EncodeText.cpp, 將它分成兩個程式 Encoding.cpp 和 Decoding.cpp, 分別用來讀取檔案, 將檔案內容編碼或解碼後, 存於另外一個檔案中 在程式 Encoding.cpp 中, 函數 Encode() 將檔案內容編碼 在程式 Decoding.cpp 中, 函數 Decode() 將檔案內容解碼

30 範例程式 檔案 Encoding.cpp // Encoding.cpp #include <iostream> #include <fstream> using namespace std; // --- 函數的宣告 void GetString (char *FileNameIn, char *String); void Encode(char *String); void WriteString (char *, char *, int Mode); int main ()// --- 主程式 char FileNameIn[20] = "OriginalText.txt"; char FileNameOut[20] = "EncodedText.txt"; const int MaxLength = 40; char String[MaxLength]; GetString(FileNameIn, String); 59/69 Encode(String); cout << " 編碼後的內容是 :\n" << String << endl; WriteString (FileNameOut, String, 0); return 0; // --- 函數 GetString () 的定義 void GetString (char *FileNameIn, char *String) ifstream FileInput; FileInput.open( FileNameIn ); if (!FileInput) cout << " 檔案 : " << FileNameIn << " 開啟失敗!\n"; exit(1); 60/69

31 FileInput.getline(String,MaxLength); FileInput.close(); cout << " 檔案 : " << FileNameIn << " 開啟成功,\n 下列是原有檔案內容 :\n" << String << endl; // --- 函數 Encode() 的定義 void Encode(char *String) char Codes[28]= "DOJKZCTMYPAWHUQNBVGSRFXLIE "; char ABC[28] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; char abc[28] = "abcdefghijklmnopqrstuvwxyz "; 61/69 62/69 int i, j, Size=strlen(String); for(i=0; i< Size; i++) j=0; while( String[i]!=ABC[j] && String[i]!= abc[j] && j<26 ) j++; String[i]=Codes[j]; return; // --- 函數 WriteString () 的定義 void WriteString (char *FileNameOut, char *String, int Mode)

32 ofstream FileOutput; if (Mode) FileOutput.open( FileNameOut, ios::app); else FileOutput.open( FileNameOut, ios::out); if (!FileOutput) cout << 檔案 : 失敗!\n"; exit(1); << FileNameOut << 存檔 FileOutput << String; FileOutput.close(); cout << " 成功存於檔案 " << FileNameOut << " 內.\n"; return; 63/69 範例程式 2 檔案 Decoding.cpp // Decoding.cpp #include <iostream> #include <fstream> using namespace std; // --- 函數 GetString() 的宣告 void GetString (char *FileNameIn,char *String); // --- 函數 Decode() 的宣告 void Decode(char *String); // --- 函數 WriteString () 的宣告 void WriteString (char *, char *, int Mode); const int MaxLength = 40; // === 主程式 ================================ int main () 64/69

33 char FileNameIn[20] = "EncodedText.txt"; char FileNameOut[20] = "DecodedText.txt"; char String[MaxLength]; GetString(FileNameIn, String); Decode(String); cout << " 解碼後的內容是 :\n" << String << endl; WriteString (FileNameOut, String, 0); return 0; // === 函數 GetString () 的定義 ================ void GetString (char *FileNameIn, char *String) ifstream FileInput; FileInput.open( FileNameIn ); if (!FileInput) cout<< 檔案 : << FileNameIn << 開啟失敗!\n";exit(1); FileInput.getline(String,MaxLength); 65/69 FileInput.close(); cout << " 檔案 : " << FileNameIn << " 開啟成功,\n 下列是原有檔案內容 :\n" << String << endl; // === 函數 Decode() 的定義 ================== void Decode(char *String) char Codes[28]= "DOJKZCTMYPAWHUQNBVGSRFXLIE "; char ABC[28] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; int i, j, Size = strlen(string); for (i=0; i<size;i++) j=0; while (String[i]!=Codes[j] && j<26) j++; String[i]=ABC[j]; 66/69

34 // === 函數 WriteString() 的定義 ============= void WriteString (char *FileNameOut, char *String, int Mode) ofstream FileOutput; if (Mode) FileOutput.open( FileNameOut, ios::app); else FileOutput.open( FileNameOut, ios::out); if (!FileOutput) cout << 檔案 : << FileNameOut << " 存檔失 67/69 敗!\n"; exit(1); FileOutput << String; FileOutput.close(); cout << " 成功存於檔案 " << FileNameOut << " 內." << endl; 操作結果 執行 Encoding.exe 在顯示器上會看到下列訊息 : 檔案 :OriginalText.txt 開啟成功, 下列是原有檔案內容 : I love you. 編碼後的內容是 : Y WQFZ IQR 成功存於檔案 EncodedText.txt 內. 執行 Decoding.exe 在顯示器上會看到下列訊息 : 68/69 檔案 :EncodedText.txt 開啟成功, 下列是原有檔案內容 : Y WQFZ IQR 解碼後的內容是 : I LOVE YOU 成功存於檔案 DecodedText.txt 內.

35 操作結果 檔案 OriginalText.txt 的內容是 : I LOVE YOU 檔案 EncodedText.txt 的內容是 : Y WQFZ IQR 檔案 DecodedText.txt 的內容是 : I LOVE YOU 69/69

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

第八﹑九章 I/O系統

第八﹑九章 I/O系統 第八 九章 I/O 系統 檔案 I/O 的基本概念 格式化 I/O 建立自訂的嵌入子 建立自訂的擷取子 自訂 I/O 與檔案 檔案 I/O 的基本概念 C++ 對 I/O 的支援是放在 中, 而 Class ios 包括有許多成員函數與變數可以用來控制和監督串流的運作. 要處理檔案 I/O, 心必須 #include, 它包含了 ifstream,ofstream

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

Microsoft PowerPoint - CPP-Ch Print.ppt [兼容模式]

Microsoft PowerPoint - CPP-Ch Print.ppt [兼容模式] Chapter 17 File Processing http://jssec.seu.edu.cn 杨明 yangming2002@seu.edu.cn OBJECTIVES To create, read, write and update files. Sequential file processing. Random-access file processing. To use high-performance

More information

FY.DOC

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

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

CC213

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

More information

Microsoft 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

Strings

Strings Streams and File I/O Cheng-Chin Chiang Streams 串流是 C++ 中一種負責資料輸出入程式的機制 輸入串流 : 資料流入程式 鍵盤 程式 檔案 程式 輸出串流 : 資料流出程式 程式 螢幕 程式 檔案 String Usage 我們已經學過的串流 cn: 鍵盤輸入串流 cout:: 螢幕輸出串流 我們可以定義其他形式的串流 例如 : 檔案輸入或檔案輸出 使用方法與

More information

Microsoft PowerPoint - Class5.pptx

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

More information

C/C++语言 - 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_cpp

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

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

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

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

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

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

第3章.doc

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

More information

untitled

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

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

untitled

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

More information

Microsoft PowerPoint - C-Ch12.ppt

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

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

105A 資管一程式設計實驗 06 函式定義謝明哲老師 2 程式設計實驗 6.3: 自行定義一個可以接受兩個整數並傳回其最大公因數的函式, 接著利用該函式自 行定義一個可以接受兩個整數並傳回其最小公倍數函式 // gcd_fcn.cpp int gcd(int m,

105A 資管一程式設計實驗 06 函式定義謝明哲老師 2 程式設計實驗 6.3: 自行定義一個可以接受兩個整數並傳回其最大公因數的函式, 接著利用該函式自 行定義一個可以接受兩個整數並傳回其最小公倍數函式 // gcd_fcn.cpp int gcd(int m, 105A 資管一程式設計實驗 06 函式定義謝明哲老師 hmz@nttu.edu.tw 1 程式設計實驗 06 函式定義 模擬問題 03 在模擬問題 02, 小組已完成擬定一個與學習或日常生活有關的問題, 並依據在 Ch5 所 學到的流程控制與檔案存取技術發展小組的第二版個別化資訊服務程式 現在請小組對第二版程式的 結構進行分析, 檢查是否有哪些功能可以使用在 Ch6 所學到的函式定義來加以模組化,

More information

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

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

More information

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

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

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

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

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

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

More information

ebook55-13

ebook55-13 1 3 C + + C C + + 13.1 X 256 C + + p r i v a t e p u b l i c p e r m u t e () X X Y 13.2 Y Y X 13 257 Y X Y X X m a i n () s i z e o f ( Y s i z e o f ( X ) p u b l i c p r i v a t e p u b l i c p r i

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 PowerPoint - 11_Templates.ppt

Microsoft PowerPoint - 11_Templates.ppt 1 1. 上機考 20% 期末考 6/23( 四 ) 晚 6:30~8:30 範圍 : 第 7, 8, 9, 10 章實習內容 按座位坐, 隨機抽兩題 2. 紙上測驗 20% 6/21( 二 ) :9:30~11:00 課本 7-11, 13 章內容 2 第 11 章樣版 (Templates) 11.1 簡介 11.2 函式樣版 11.3 多載函式樣版 11.4 類別樣版 11.5 類別樣版與無型

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

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

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 Java V1.0.1 2007 4 10 1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 6.2.10 6.3..10 6.4 11 7.12 7.1

More information

迅速在两个含有大量数据的文件中寻找相同的数据

迅速在两个含有大量数据的文件中寻找相同的数据 迅速在两个含有大量数据的文件中寻找相同的数据 求解问题如下 : 在本地磁盘里面有 file1 和 file2 两个文件, 每一个文件包含 500 万条随机整数 ( 可以重复 ), 最大不超过 2147483648 也就是一个 int 表示范围 要求写程序将两个文件中都含有的整数输出到一个新文件中 要求 : 1. 程序的运行时间不超过 5 秒钟 2. 没有内存泄漏 3. 代码规范, 能要考虑到出错情况

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

玉山科技AES加密工具程式說明書

玉山科技AES加密工具程式說明書 AES 加密工具程式 說明書 一 前言 2 二 API 使用說明 3 三 範例說明 11 一 前言 AES (Advanced Encryption System) 是目前非常安全且運算效能相對快速的對稱式演算法, 以下摘自 Wikipedia 網站的說明 : (WikiPedia) In cryptography, the Advanced Encryption Standard (AES), also

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

Microsoft Word - 01.DOC

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

More information

Microsoft Word - CH09

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

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

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

Microsoft PowerPoint - C-Ch11.ppt

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

More information

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

Microsoft PowerPoint - Chap03.ppt [相容模式] 本章目的 2D / 3D 遊戲程式設計入門使用 XNA 3.0 與 C# 探討 XNA 遊戲程式內部的基本架構與遊戲開發流程 示範如何完成一個簡單的 XNA 遊戲方案 第三章 XNA 遊戲程式基本架構 1 2 新增 XNA 專案 新增 XNA 專案 3 4 XNA 相關的命名空間 Game1.cs 程式中的六個函數 using Microsoft.Xna.Framework; // 和 XNA 架構相關的型別

More information

Microsoft Word - ch04三校.doc

Microsoft Word - ch04三校.doc 4-1 4-1-1 (Object) (State) (Behavior) ( ) ( ) ( method) ( properties) ( functions) 4-2 4-1-2 (Message) ( ) ( ) ( ) A B A ( ) ( ) ( YourCar) ( changegear) ( lowergear) 4-1-3 (Class) (Blueprint) 4-3 changegear

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

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

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

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

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

More information

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

第1章

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

More information

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

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

投影片 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

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

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

運算子多載 Operator Overloading

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

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

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

untitled

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

More information

Microsoft PowerPoint - C-Ch08.ppt

Microsoft PowerPoint - C-Ch08.ppt 函數 8-1 函數 函數 (function) 可以整合某些特定的處理 整合好的處理可以隨時呼叫使用 C 語言的程式本身也是一個函數, 也就是 main() 函數 使用函數可簡化程式 提款的處理 1. 將提款卡插入自動提款機當中 2. 輸入個人密碼 3. 指定提款金額 4. 領取款項 5. 確認款項與提款卡 提款處理 8-2 函數的定義與呼叫 定義函數的語法 : 傳回值的型態函數名稱 ( 引數列表

More information

1

1 守大學電機系 電腦視覺 報告 單元一 數位影像 : 格式和操作 參考解答 MIAT( 機器智慧與自動化技術 ) 實驗室 中華民國 93 年 9 月 29 日 1. (a) 如果指紋影像 finger300x300 的取像面積是 14(mm)x14(mm), 請計算取像系統的 dpi (b) 如果 kaoshiung512x512 遙測影像的覆蓋面積是 5(Km)x5(Km), 請計算該影像的解析度

More information

计算机网络编程

计算机网络编程 计算机网络编程 第 3 章 Ethernet 帧的封装与解析 信息工程学院方徽星 fanghuixing@hotmail.com 大纲 设计目的 相关知识 例题分析 1. 设计目的 帧是在数据链路层进行数据传输的基本单元 目的 : 根据数据链路层的基本原理, 通过封装标准格式的 Ethernet 帧, 了解 Ethernet 帧结构中各字段的含义与用途, 从而深入理解网络协议的工作原理 2. 相关知识

More information

JavaIO.PDF

JavaIO.PDF O u t p u t S t ream j a v a. i o. O u t p u t S t r e a m w r i t e () f l u s h () c l o s e () public abstract void write(int b) throws IOException public void write(byte[] data) throws IOException

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 - C-Ch10.ppt

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

More information

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

提问袁小兵:

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

More information

Microsoft Word - 970617cppFinalSolution.doc

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

More information

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

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

More information

第1章

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

More information

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

第十一章 流类库与输入/输出

第十一章 流类库与输入/输出 第十一章流类库与输入 / 输出 本章主要内容 I/O 流的概念 输出流 输入流 输入 / 输出流 2 I/O 流的概念 当程序与外界环境进行信息交换时, 存在着两个对象, 一个是程序中的对象, 另一个是文件对象 流是一种抽象, 它负责在数据的生产者和数据的消费者之间建立联系, 并管理数据的流动 程序建立一个流对象, 并指定这个流对象与某个文件对象建立连接, 程序操作流对象, 流对象通过文件系统对所连接的文件对象产生作用

More information

Template

Template 第十一章 ( 上篇 ) 函數樣板 (Function Template) 與 類別樣板 (Class Template) 建立通用函數 (Generic Functions) & 通用類別 (Generic Classes) - Code Reuse 的另一種發揮 - 煩人的事經歷一次就夠了 1 為何需要通用函數? int abs(int x) { return (x>0)?x:-x; int abs(int

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

Microsoft Word - well_game.doc

Microsoft Word - well_game.doc 智慧型系統控制 趙春棠老師 四技機電四甲 49422019 黃秉宏 井字遊戲並沒有什麼必勝的著法, 但只要適當的回應, 就可保持不敗 也 1 2 3 4 5 6 7 8 9 法則 手玩家的最佳著法其第一步最好下在四個角落 ( 即 2 4 6 8 號位置 ), 因為後手玩家除了下在中央的 5 號位置之外必敗 即使對手下了該位置, 只要回以馬步佈局或對角佈局也還有一半的勝算 先手玩家第一步的次佳選擇在

More information

untitled

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

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

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

Strings

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

More information

C++ 程序设计 实验 2 - 参考答案 MASTER 2017 年 5 月 21 日 1

C++ 程序设计 实验 2 - 参考答案 MASTER 2017 年 5 月 21 日 1 C++ 程序设计 实验 2 - 参考答案 MASTER 2017 年 5 月 21 日 1 1 CRECT 类 1 CRect 类 设计矩形类, 包含 长度和宽度信息 基本构造函数 基础属性的访问接口 ( 读 / 写, Read/Write, Get/Set) 计算周长和面积 ( 注 : 基本构造函数, 一个无参数的默认构造函数, 以及一个初始化数据成员的构造函数如果数据成员的初始化有多种形式, 就提供多个构造函数

More information

bingdian001.com

bingdian001.com TSM12M TSM12 STM8L152C6, STM8L152R8 MSP430F5325 whym1987@126.com! /******************************************************************************* * : TSM12.c * : * : 2013/10/21 * : TSM12, STM8L f(sysclk)

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

White Sketchpad PowerPoint Presentation

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

More information

Microsoft PowerPoint - ch03_AEL0080.ppt

Microsoft PowerPoint - ch03_AEL0080.ppt 3 基本資料型態 能盡物之性, 則可以贊天地之化育 可以贊天地之化育, 則可以與天地矣 中庸中庸.第二十一章第二十一章 1/88 基本資料型態 3.1 3.2 3.3 3.4 3.5 3.6 3.7 整數和浮點數變數和常數算術運算標準數學函數的運算邏輯值及其運算字元與字串位元處理運算 2/88 C++ 的資料型態 C++ 資料型態 基本資料型態 整數 int, short, long 浮點數 float,

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

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

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

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

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

More information

四川省普通高等学校

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

More information

C語言

C語言 Chapter 1 Introduction 本 章 重 點 1-1 程 式 與 軟 體 1-2 程 式 語 言 種 類 1-3 程 式 硬 體 執 行 流 程 1-4 程 式 設 計 技 術 1-5 C 歷 史 簡 介 1-6 C 執 行 平 台 說 明 1-1 程 式 與 軟 體 一 電 腦 系 統 ALU CPU L1 cache Hardware system 週 邊 設 備 Computer

More information

運算子多載 Operator Overloading

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

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