algorithm C++ · 头文件
标准算法头文件,提供 sort、find、min、max、reverse 等常用算法。
怎么用
#include <algorithm>
小例子
#include <algorithm>
#include <vector>
std::vector<int> v = {3, 1, 2};
std::sort(v.begin(), v.end());
for (int x : v) std::cout << x;
运行结果
123
提醒:这些算法大多操作迭代器范围 [begin, end),sort 需要随机访问迭代器
在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← C++全部词条