# 2024 交大電機營 C++ 統整練習 --- ### 題目敘述       ### 流程圖  ### 程式碼架構 ```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; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up