# 2024 交大電機營 C++ 統整練習 --- ### 題目敘述 ![446032130_1147019179779555_5625047366159684492_n](https://hackmd.io/_uploads/BynYe9JV0.png) ![441515261_1188820732019608_3893210018631632332_n](https://hackmd.io/_uploads/Bk-Fg9yNA.png) ![441059185_346953238073678_7175795794373320700_n](https://hackmd.io/_uploads/B1jdx91EC.png) ![440941322_3802754629944582_7782054026007685740_n](https://hackmd.io/_uploads/SyVDlq140.png) ![441895030_3375859156040047_4643497113590191065_n](https://hackmd.io/_uploads/rkIYlqJVC.png) ![445978893_970237101554783_4504910645241494366_n](https://hackmd.io/_uploads/H1cKe5JNC.png) ### 流程圖 ![2024_統整練習_流程圖](https://hackmd.io/_uploads/r1mZEiOw0.jpg) ### 程式碼架構 ```C++= #include <iostream> using namespace std; int main() { int mode = 0; //宣告一個選功能的變數 int max = 0, min = 0; //宣告用來尋找最大最小值的變數 int array[10] = {0}; //宣告一個長度為10的一維陣列並初始化 cout << "Please enter an array:\n"; //TODO: 輸入陣列 while(1) { //無限迴圈 cout << "Choose a mode: "; cin >> mode; if(mode == 1) { //功能為1 /* TODO: 正向輸出陣列並換行 */ cout << "Print the array in order:\n"; } else if(mode == 2) { //功能為2 /* TODO: 反向輸出陣列並換行 */ cout << "Print the array in reverse order:\n"; } else if(mode == 3) { //功能為3 /* TODO: 輸入新陣列 */ cout << "Please enter a new array:\n"; /* TODO: 正向輸出新陣列並換行 */ cout << "Your new array is:\n"; } else if(mode == 4) { //功能為4 /* TODO: 找出最大值 */ cout << "The maximum value is " << max << " at index "; /* TODO: 輸出所有最大值的索引值並換行 */ } else if(mode == 5) { //功能為5 /* TODO: 找出最小值 */ cout << "The minimum value is " << min << " at index "; /* TODO: 輸出所有最小值的索引值並換行 */ } else if(mode == 6) { //功能為6 cout << "Terminate the code\n"; /* TODO: 跳出迴圈 */ } else { //功能選擇錯誤 cout << "Error, no such mode exist\n"; } } return 0; } ```