鄭余玄
    • 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 --- # 回顧與展望 ###### 06.23 鄭余玄 ---- ## 小提醒 - 隨著課程進入尾聲 - 記得下週是階段考喔 ---- ## 第十八週 06/30 第二階段檢定考試 - 規則與第一次相同 - 上機考 - 可以上網查 - 不能使用任何形式交談 - 自由去廁所 - 不克前來,記得提前**請假** --- # 資訊之芽回顧 ###### 大抄(? ---- ## 第一階段 - 基礎語法 - 流程控制 - 字串 - 函數 - 基礎迴圈 ---- ## 第二階段 - 更多語法 - C++ 字串、串流 - 指標、參考(reference) - 動態記憶體:```new```, ```delete``` - 更多遞迴 - 結構(struct) - 串列、雙向串列 - 檔案流 - 標頭檔 ---- ## 第二階段 - 演算法:好壞? - 排序:氣泡、插入、選擇 - 二分搜尋法 - 標準模板庫、範式 - vector, list - stack, queue, deque - iterator - sort, next_permutation ---- ## C++ String ```#include <string>``` ```std::string myname = "sprout";``` - 長度 ```c++ size_t len = myname.length(); ``` - 插入 ```c++ sprout.insert(6, "zzz");// sprout == "sproutzzz" ``` ---- ## C++ String - 比較:字典序比較 - 尋找子字串 ```c++ size_t pos = myname.find("pro"); // 判斷是否找不到 pos == std::string::npos ``` ---- ## C++ 串流格式 ```#include <iomanip>``` - **注意**:最後一個輸出格式,會影響之後的輸出 - 輸出 16 進位 ```c++ std::cout << std::hex << 123; ``` - 輸出小數點後第二位 ```c++ std::cout << std::fixed << std::setprecision(2) << 3.1415926; ``` ---- ## stringstream ```#include <sstream>``` ```std::stringstream ss;``` - ex: 數字轉字串 - 輸入:```ss << XXX;``` - 輸出:```ss >> OOO;``` - 清空:```ss.clear();``` ---- ## 指標與參考 - 指標 - **注意**:宣告多個指標 ```int *a, *b;``` ```c++ int x = 123; // 取值 x, 取位址 &x int *ptr; // ptr(的值)存位址,指向 int ptr = &x; *ptr = 456; // 取值 ptr, 取指向位址中的值 *ptr ``` ```c++ int b[5] = {2, 3, 5, 7, 8}; *(b + 3); // == b[3] ``` - 參考:當作一般變數操作 ```c++ int x = 123; int &y = x; y = 456; ``` ---- ## 函數傳遞參數 - 傳值:```void swap(int a, int b);``` - 指標:```void swap(int *a, int *b);``` - 參考:```void swap(int &a, int &b);``` ---- ## 動態記憶體 - ```new``` 使用之後**記得 ```delete```** ```c++ int n; Student *stu = new Student[n]; delete[] stu; ``` ---- ## 結構(struct) - 一般變數 ```c++ SproutStudent sprout; sprout.grade; ``` - 指標變數 ```c++ SproutStudent *sptr = &sprout; sptr->grade; ``` - 函數傳遞參數 ```c++ bool isPass(const Student& rhs); int totalGrade(const Student rhs[]); ``` ---- ## 串列 - 單向 ![](https://i.imgur.com/RhqZWKG.png) - 雙向 ![](https://i.imgur.com/3cY2Dwo.png) ---- ## 排序 - 氣泡:兩兩交換 - 選擇:從未排最小,放到已排序中 ---- ## 二分搜尋 - *已經排序*完的陣列 ![](https://i.imgur.com/nYl4xkq.png) ---- ## 標準模板庫 STL - ```vector```:伸縮自如的陣列 - ```list```:雙向鏈結串列 - ```stack```:類似疊東西,優先取得最後的資料 - ```queue```:類似排隊,優先取得最早的資料 ---- ## 迭代器(iterator) - 用來遍歷容器所有元素 ```c++ std::vector<int> vec; std::vector<int>::iterator it; it = vec.begin(); for (; it != vec.end(); ++it) { std::cout << *it << std::endl; } ``` - 新增、刪除:```insert```, ```erase``` - **注意**:刪除後的 iterator 會失效 ---- ## ```std::sort``` 排序 ```#include <algorithm>``` ```c++ int arr[5]; std::sort(arr, arr + 5); vector<int> vec; std::sort(vec.begin(), vec.end()); ``` - 自訂排序 ```c++ struct Position { int x, y; }; // 如果 a < b 回傳 true, 反之 false bool compare(const Position& a, const Position& b) { return (a.x < b.x || (a.x == b.x && a.y < b.y)); } Position pos[4] std::sort(pos, pos + 4, compare); ``` ---- ## ```std::next_permutation``` 下個字典序 ```#include <algorithm>``` ```c++ int s[] = {1, 2, 3}; do { std::cout << s << std::endl; } while (std::next_permutation(s, s + 3)); ```

    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