Created
October 2, 2017 09:42
-
-
Save goodjack/c85ae5de0e0b0516be1593cbb7a5fefd to your computer and use it in GitHub Desktop.
1. 參考解答:Hello World and if/else
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
// 輸出 “Hello World” | |
cout << "Hello World"; | |
// 判斷 num 是偶數還是奇數 | |
int num = 5; // 指定整數變數 num 為 5 | |
if (num % 2 == 0) { // 如果除以 2 餘 0 | |
cout << "num 是偶數"; | |
} else { // 否則(除以 2 不餘 0) | |
cout << "num 是奇數"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment