## [題目一]-開始寫程式(5mins) ```cpp /*匯入函式庫*/ /*使用std命名空間*/ int main() { cout //接下去寫 cout //接下去寫 /*程式結束 回傳0*/ } ``` ## [題目二]-變數(10mins) ```cpp #include<iostream> using namespace std; int main() { int /*宣告變數*/ float /*宣告變數*/ char /*宣告變數*/ bool /*宣告變數*/ cout << /*字串*/ << /*變數*/ << endl; cout << /*字串*/ << /*變數*/ << endl; cout << /*字串*/ << /*變數*/ << endl; cout << /*字串*/ << /*變數*/ << endl; return 0; } ``` ## [題目三]- Cin(5mins) ```cpp #include<iostream> using namespace std; int main() { int /*宣告並初始化變數*/ cin /*依次輸入三個變數的值*/ cout << "the input date is: " << /*輸出變數*/ << endl; return 0; } ``` ## [題目四]-Boolean(5mins) ```cpp #include<iostream> using namespace std; int main() { int score = 0; int /*可以在宣告另一個變數*/ cin >> score; cout << /*輸出*/ << endl; return 0; } ``` ## [題目五]-選擇控制(10mins) ```cpp #include<iostream> using namespace std; int main() { /*宣告變數*/ cout << "Please enter a score: "; /*輸入成績*/ if(/*判斷不合法的輸入*/) { /*輸出*/ } else { if(/*第一種情況*/) { /*輸出*/ } else if(/*第二種情況*/) { /*輸出*/ } else { /*輸出*/ } } return 0; } ``` ## [題目六]-While迴圈(5mins) ```cpp #include <iostream> using namespace std; int main() { int /*初始化*/; while (/*條件*/) { cout << i << " " << endl; /*更新*/ } return 0; } ``` ## [題目七]-For迴圈(10mins) ```cpp #include <iostream> using namespace std; int main() { for (int /*初始化*/; /*結束條件*/; i++) { /*判斷偶數並輸出*/ } return 0; } ``` ## [題目八]-陣列(10mins) ```cpp #include <iostream> using namespace std; int main() { int arr[5][5]; for (int i = 0; i < 5; i++) { /*賦值*/ } for (int i = 0; i < 5; i++) { /*印出陣列值*/ } return 0; } ``` ## [題目九]-函式 (10mins) ```cpp #include <iostream> using namespace std; int factorial(int n) { int result =/*結果初始化*/; for (/**/) { /*計算階乘*/ } return result; } int main() { int n; cin >> n; cout << factorial(n) << endl; 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