1. 字符串查找字符
bool findMap(char ch){string mapper = "aeiouAEIOU";return mapper.find(ch) != string::npos;}
2.substr函數
string substr(size_t pos = 0, size_t len = npos) const;
3.to_string && stoi 函數??????
iota?填充一個范圍(range)?以?連續的遞增值;void iota(ForwardIt first, ForwardIt last, T value);
4.std::stack
?的?pop()
?函數不返回任何值(返回類型為?void
)
5.INT_MAX
int數字轉化為long數字
(long)spells[idx[i]]*potions[c]
6. 三元運算符優先級要低于運算符+/-,所以三元運算符需要加括號
int max = (a > b) ? a : b;
7.?&
(引用):變量的別名,更安全、更簡潔,適合函數參數傳遞;*
(指針):存儲地址,更靈活,適合動態內存管理和數據結構。
8.防止越界:
取平均數防止越界 a+(b-a)/2整數相除向上取整 (a+b-1)/b