鄭余玄
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- slideOptions: theme: serif --- # 資訊之芽 ###### 03.03 鄭余玄 ###### 2018 資訊之芽 語法班 --- # 程式語言簡介 ---- ## 程式語言 - 「可以控制機器的人造語言」 - 方便我們撰寫程式的邏輯 <!-- .element: class="fragment" data-fragment-index="1" --> - 可轉換成機器能夠看懂、可以執行的「指令」<!-- .element: class="fragment" data-fragment-index="2" --> - 隨著時間發展而具備不同特性和面向<!-- .element: class="fragment" data-fragment-index="3" --> ---- ## 程式語言類別 - 高階語言 (Ex: C, C++, Python, Java) ```c SUM = A + B ``` - 組合語言 ```asm LOAD A ADD B STORE SUM ``` - 機器語言 ```txt 01001101011111010001010000010111 01010011011110110101110000001011 01000111100010101011101001101011 ``` ---- ## 電腦的組成 抽象來說,電腦內包含了: - **中央處理單元 (CPU)** - **記體憶單元 (Memory)** - 儲存單元 (Storage),ex: 硬碟 - 輸入單元 (Input),ex: 鍵盤、滑鼠 - 輸出單元 (Output),ex: 螢幕、印表機 ---- ## 關於大家要學的 C/C++ - C 語言與 Unix 作業系統的發展密不可分 - C++ 是從 C 衍生的語言,兩者相近但**相異** - 課程中會將容易困惑的 C 語法,以 C++ 較易解釋的部份取代 <!-- .element: class="fragment" data-fragment-index="1" --> - 各位將學的是 C++ 中偏向 C 的部份,並不探討 C++ 中其他的語言特性 <!-- .element: class="fragment" data-fragment-index="2" --> --- # C 新手入門 ## Hello World ---- ![](https://i.imgur.com/h8CIpjm.png) ---- ## 課程使用軟體 - 整合開發環境 (IDE) - **Dev-C++** (上課使用此軟體) - Microsoft Visual Studio - 編譯器 (Compiler) - GNU Compiler Collection (gcc, g++) - Intel C++ Compiler (icc, icpc) ---- # Hello World! - 請開啟一個新專案,輸入下列程式碼後編譯並執行 ```c++ #include <iostream> using namespace std; int main() { cout << "Hello World!" << endl; return 0; } ``` ---- ## 也可以這樣寫 ```c++ #include <iostream> int main() { std::cout << "Hello World!" << std::endl; return 0; } ``` ---- ## 簡略說明 ```c++ #include <iostream> // 加註解 int main() { std::cout << "Hello World!" << std::endl; // 要記得加上分號 return 0; } ``` - ```//```,加上單行程式碼註解(給人看的,隨意寫) - ```#```,開頭的是前置處理指令(給編譯器看的) ```c++ #include <檔案名> ``` - ```std::cout``` 和 ```std::endl``` 都是在 ```iostream``` 中 ---- ## 主程式 ```c++ #include <iostream> using namespace std; int main() { cout << "Hello World!" << endl; // 分號很重要!! return 0; // 分號很重要!! } ``` - ```int```,整數 integer,後面有詳細介紹 - ```main()```,程式進入點 - ```{}```,程式區塊範圍 - ```return 0;```,程式正常結束 ---- ## 標準輸入輸出 ```c++ std::cout << "Hello World!" << std::endl; ``` - ```std::cout```,輸出到螢幕 (console output) - ```<<```,串接要輸出的東西 - ```std::endl```,輸出換行(end-of-line) - 「**```;```**」,結束這行指令 ---- ## 串接 ```c++ std::cout << "Hello World!" << std::endl << "我愛資芽!"; ``` 或是 ```c++ std::cout << "Hello World!" << std::endl; std::cout << "我愛資芽!"; ``` ---- ## Tips - cout 唸作「see-out」,不是~~靠~~ - 指令(陳述式)結尾加「```;```」 - 不計換行、空白、定位(Tab),可以幫助程式碼編排 ```c++ #include <iostream> using namespace std; int main( ) { cout << "Hello World!" << endl; return 0; } ``` ---- ## 小練習 1\. 執行下列程式碼,看看有什麼不同 ```c++ #include <iostream> using namespace std; int main() { cout << "1 + 1" << endl; cout << 1 + 1 << endl; return 0; } ``` --- # 線上平測系統 (OJ) 教學 http://neoj.sprout.tw/</pre>

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    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

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully