Skip to content

Instantly share code, notes, and snippets.

@goodjack
Created October 2, 2017 09:42
Show Gist options
  • Save goodjack/c85ae5de0e0b0516be1593cbb7a5fefd to your computer and use it in GitHub Desktop.
Save goodjack/c85ae5de0e0b0516be1593cbb7a5fefd to your computer and use it in GitHub Desktop.
1. 參考解答:Hello World and if/else
#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