暑期解題訓練團隊
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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 New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy 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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: Data Structure & STL tags: article --- # STL 標準模板庫(Standard Template Library) ## [<cmath> (math.h)](https://www.cplusplus.com/reference/cmath/) (for C/C++) 提供數學函式可以直接引用,包含絕對值(abs)、三角函數(sin, cos, ...)、根號(sqrt) ...等 ## [<algorithm>](https://www.cplusplus.com/reference/algorithm/) (for C++) 提供已寫好的算法函式,包含排序(sort)、最小值(min)、最大值(max)、 反轉陣列(reverse)、交換(swap)...等。 ## [<iomanip>](https://www.cplusplus.com/reference/iomanip/) (for C++) iomanip提供<iostream>之輸出的輔助功能,包含決定小數點位數(setprecision)、 每次輸出間隔(setw)...等。 - [I/O 格式控制器](https://openhome.cc/Gossip/CppGossip/IOFormatController.html) - [cout控制輸出的小數點位數](http://it-easy.tw/cout-float/) ## [<sstream>](https://www.cplusplus.com/reference/sstream/) (for C++) sstream提供stringstream物件,可以用來做如同iostream的流入(<<)和流出(>>)的操作, 也有些人會拿stringstream來處理字串轉換成int之類的用法。 - [[C++] StringStream-int和sting轉換的另一種方案與清空StringStream](https://dotblogs.com.tw/v6610688/2013/11/08/cplusplus_stringstream_int_and_string_convert_and_clear) --- # STL Container (C++ only) ## [<queue>](https://www.cplusplus.com/reference/queue/queue/), [<stack>](https://www.cplusplus.com/reference/stack/stack/), [<deque>](https://www.cplusplus.com/reference/deque/deque/), [<vector>](https://www.cplusplus.com/reference/vector/vector/), [<list>](https://www.cplusplus.com/reference/list/list/) **queue** : 先進的後出,排隊的概念。 **stack** : 先進的先出,疊盤子的概念。 **deque** : 等同於 queue + stack,兩邊都可以操作。 **vector** : 動態陣列。 **list** : 雙向的鏈結串列。 提供多種線性資料結構,其中又以vector最為常見, 各項資料結構的使用方式可以參考以下文章: - [資訊之芽C語法班2020 - STL Data Structure](https://hackmd.io/@htting/HksIP5wiI#/7) --- ## [<set>](https://www.cplusplus.com/reference/set/set/), [<map>](https://www.cplusplus.com/reference/map/map/), [<priority_queue>](http://www.cplusplus.com/reference/queue/priority_queue/) **set** : 每個元素僅可存放一次,並且會將元素順序作排列。 **map** : 如同 (key,value) 的功能,其原理便是利用set + pair的方式做儲存。 **priority_queue** : 權重佇列,權重越大的元素會被擺在top。 提供幾種排序型/樹狀的資料結構,其中以map最為常見, 各項資料結構的使用方式可以參考以下文章: - [set vs map in C++ STL - GeeksforGeeks](https://www.geeksforgeeks.org/set-vs-map-c-stl/) - [C++ - Map (STL) 用法與心得完全攻略](https://mropengate.blogspot.com/2015/12/cc-map-stl.html) - [C++ std::set 用法與範例](https://shengyu7697.github.io/std-set/) - [常用C++ STL:priority_queue - YUI HUANG 演算法學習筆記](https://yuihuang.com/cpp-stl-priority-queue/) --- ## [pair (in <utility>)](https://www.cplusplus.com/reference/utility/), [<tuple>](https://en.cppreference.com/w/cpp/utility/tuple), [<bitset>](https://www.cplusplus.com/reference/bitset/bitset/) **pair** : 可以存放兩個元素的資料結構。 **tuple** : 可以存放多個元素的資料結構。 **bitset** : 可以用來儲存位元值,處理位元運算等功能,其功能性非常強大。 特殊的資料結構,pair與tuple功能相近,但tuple的擴展性更高, 各項資料結構的使用方式可以參考以下文章: - [c++ pair 用法詳解](https://www.itread01.com/content/1548114125.html) - [tuple in C++ 11 | 打字猴](https://coherence0815.wordpress.com/2015/12/19/tuple-in-c-11/) - [【c++標準函式庫(STL)筆記】bitset 介紹](https://ithelp.ithome.com.tw/articles/10231549) --- # 其他可參考資料與彙整 其他詳細的STL函式與其說明可以參考以下資料: - [C++ Reference ( Standard C++ Library reference )](https://www.cplusplus.com/reference/) - [建中資訊培訓講義2017 - 簡介、STL 資料結構及 algorithm 初階](https://tioj.ck.tp.edu.tw/uploads/attachment/11/40/1.pdf)

    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