encrypt01.h
// 從標準程式庫中引入 string #include <string> // 使用 std 中的 string 名稱 using std::string; // 宣告 Encrypt 類別 class Encrypt { public: // 宣告建構函數 Encrypt(); // 宣告 setter 與 getter 成員函數 void set_code_array(); string get_code_array(); // 宣告編碼、解碼的成員函數 string ToEncode(string); string ToDecode(string); private: // 密碼表字串 string code_array; }; /* 檔名: encrypt01.h 作者: Kaiching Chang 時間: 2014-5 */
exercise1401.cpp
#include <iostream> using namespace std; int main(void) { int a[10]; int i; for (i = 0; i < 10; i++) { a[i] = 9527; } cout << endl; for (i = 0; i < 10; i++) { cout << a[i] << ", "; } cout << endl << endl; return 0; } /* 檔名: exercise1401.cpp 作者: Kaiching Chang 時間: 2014-5 */
exercise1402.cpp
#include <iostream> using namespace std; int main(void) { char a[26]; char c = 'a'; int i; for (i = 0; i < 26; i++) { a[i] = c++; } cout << endl; for (i = 0; i < 26; i++) { cout << a[i] << ", "; } cout << endl << endl; return 0; } /* 檔名: exercise1402.cpp 作者: Kaiching Chang 時間: 2014-5 */
exercise1403.cpp
#include <iostream> using namespace std; int main(void) { int answer = 1234; cout << answer << endl; } /* 檔名: exercise1403.cpp 作者: Kaiching Chang 時間: 2014-5 */
exercise1404.cpp
#include <iostream> using namespace std; int main(void) { int answer = 1234; //cout << answer << endl; int guess; cin >> guess; if (answer == guess) { cout << "Right!!" << endl; } else { cout << "Wrong!!" << endl; } } /* 檔名: exercise1404.cpp 作者: Kaiching Chang 時間: 2014-5 */
exercise1405.cpp
#include <iostream> using namespace std; int main(void) { int answer = 1234; //cout << answer << endl; int i, j; int answer_array[4]; j = 1000; for (i = 0; i < 4; i++) { answer_array[i] = answer / j; j /= 10; } int guess; cin >> guess; int guess_array[4]; j = 1000; for (i = 0; i < 4; i++) { guess_array[i] = guess / j; j /= 10; } int number = 0; for (i = 0; i < 4; i++) { if (guess_array[i] == answer_array[i]) { number++; } } if (number == 4) { cout << "Right!!" << endl; } else { cout << "Wrong!!" << endl; } } /* 檔名: exercise1405.cpp 作者: Kaiching Chang 時間: 2014-5 */
the end
沒有留言:
張貼留言