![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++ 知识点
道纪书生
博士在读,国家奖学金获得者,中国机器人大赛全国亚军,研究方向:CV/SVBRDF Estimation/Object Counting/Swarm Intelligence/Evolutionary Computation,学术or技术交流欢迎私信。
展开
-
Leetcode-刷题常用库函数记录【持续更新】
Vector相关1. 求数组中最大的元素 *max_element(nums.begin(), nums.end());vector <int> nums={0,1};return *max_element(nums.begin(), nums.end());2. Vector删除元素for (vector<int>::iterator it = nums.begin(); it != nums.end(); it++) if (*it == 2)原创 2022-02-02 08:51:59 · 638 阅读 · 0 评论 -
C++: unordered_map常见用法
1. 头文件#include <unordered_map>2. 初始化unordered_map<char, int>;3. 插入元素//数组形式map['a'] = 1;//直接插入map.insert( { {'b',2} , {'c',3} } );4. 修改元素map['a'] = 0;5. 删除元素//删除key为'a'的元素map.erase('a'); //删除第一个元素map.erase(map.begi原创 2021-08-26 16:10:58 · 8844 阅读 · 2 评论 -
C++:字符串转数字&&数字转字符串
字符串转数字方法一:库函数 stoi()头文件:#include <string>示例:string s="123";int num=stoi(s); // num=123说明:除了可以用stoi函数将 sting 型的数字转为 int 型的数字外,还可以使用stod() 、stof() 等函数转为double型、float型等。方法二:字符流头文件:#incude <sstream>示例:string str="123";.原创 2021-08-25 20:57:02 · 249 阅读 · 0 评论 -
C++ 哈希集用法
1. 头文件#include <unordered_set> 2. 定义unordered_set<int> hashset; 也可为其他类型,如:unordered_set<char> hashset; 3.插入元素hashset.insert('a')4.删除元素hashset.erase('a');5.查询某元素是否存在 if (hashset.count('a') > 0) {原创 2021-08-24 17:29:15 · 3170 阅读 · 0 评论