or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
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.
Syncing
xxxxxxxxxx
C++學習筆記
I/O
STL函數庫
1. vector
2. stack
3. queue
(1)queue
(2)priority queue
注意:priority queue使用struct的時候要注意bool operator的寫法
4. set
用法跟set一樣,差別於multiset可以新增重複的元素,set不行
注意:multiset的insert的返回值和set的返回值不一樣,不可混用
快速查詢,無rb tree自動排序
跟unordered_set差別於unordered_multiset可新增重複元素
注意:如要使用struct建議用multiset,因為bool operator相等就會被判定為一樣的元素,即使其他值不一樣還是會被set吃掉。
5. map
key=it->first , value=it->second
實現一對多映射,如要插入要用insert : mm.insert({key,value})
實作hash table,用法跟map一樣,只是速度比map快很多,但記憶體空間較為龐大
6. deque(double-ended queue)
7. list
雙向連結串列
algorithm
反轉
排序
如果排序元素小於16會用insert sort(元素保持stable)
超過16會用quick sort(元素不保持stable)
所以如果想要 當元素相同時但不變換原有位置,就要用stable_sort
自訂排序
string
動態配置
鄰接串列
判斷alphabet(isalpha)
轉換小寫(tolower)
字串切割(stringstream)
二分搜(lower_bound)
累積函數(accumulate)
iterator
pair
就相當於一個struct,只是限定兩個元素,用'.'存取,第一個值是first,第二個值是second
tuple
相當於一個strust,可自訂struct裡的型別和數量
上面宣告的tuple就相當於以下struct,只是存取時的元素名稱不一樣
Bitset
以bit為單位的集合,用法與二進制int一樣
可印出數字二進制
排列組合next_permutation
要列出一組數字的排列組合要先把該組數字排序,再利用nexe_permutation函數來取得下一個排列組合,如果該組排列組合已經是最大的了,會依照升序排列,並回傳false,否則回傳true
output:
fill
memset 只能初始成0跟-1,當要初始成其他值時,就可用fill
fill顧名思義就是填滿,填滿特定的值,參數如下
Binary Search
內建二分搜找元素,如果有找到回傳1,否則回傳0
隨機生成大數
範圍:long long
iota
填充1~n到陣列裡