上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 36 下一页

2021年4月28日

摘要: STL map基本使用 hash_map 基本使用 STL map基本使用 头文件#include <map> //自定义排序 class MySortMap { public: bool operator()(int v1,int v2) const { return v1>v2; } }; vo 阅读全文
posted @ 2021-04-28 15:54 lodger47 阅读(84) 评论(0) 推荐(0)
摘要: 自定义set排序 如果是自定义类型,再插入之前就要定义好,排序规则不然会报错 template<class T,class T2> void printSet(set<T,T2> &a) { for (auto it = a.begin(); it != a.end(); ++it) { cout 阅读全文
posted @ 2021-04-28 15:20 lodger47 阅读(357) 评论(0) 推荐(0)
摘要: set<int> s1; auto ret = s1.insert(10); if (ret.second) cout << "插入成功" << endl; else cout << "插入失败" << endl; auto ret2 = s1.insert(10); if (ret2.second 阅读全文
posted @ 2021-04-28 15:08 lodger47 阅读(1878) 评论(0) 推荐(0)
摘要: 对组 (不需要头文件的) //创建对组 void test02() { //第一种 pair<string, int> p(string("Tom"), 100); cout << "姓名: " << p.first << endl; cout << "年龄:" << p.second << end 阅读全文
posted @ 2021-04-28 14:59 lodger47 阅读(112) 评论(0) 推荐(0)
摘要: list.remove(xxx);删除基本类型不需要重写,自定义类型需要重写==运算符 list<Person> p; Person("xiaozhao"); p.remove(Person("xiaozhao"));//要要在Person类中重写==运算符 阅读全文
posted @ 2021-04-28 14:30 lodger47 阅读(681) 评论(0) 推荐(0)
摘要: vmnet8重启网卡 sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli - 阅读全文
posted @ 2021-04-28 00:31 lodger47 阅读(224) 评论(0) 推荐(0)

2021年4月27日

摘要: c++ 方式一 #include <random> static default_random_engine readom_engine_v(time(NULL)); readom_engine_v(); c++(生成随机数)方式二 #include <ctime> #include <random 阅读全文
posted @ 2021-04-27 18:24 lodger47 阅读(220) 评论(0) 推荐(0)
摘要: c++(sort排序) sort排序 #include <algorithm> bool sortFun(int v1, int v2) { return v1 > v2; } void test01() { deque<int> d; d.push_back(2); d.push_back(1); 阅读全文
posted @ 2021-04-27 17:42 lodger47 阅读(22) 评论(0) 推荐(0)
摘要: c++(vector 开辟的空间的优化) 若提前知道大概需要开辟的空间这样写会优化代码 void test01() { vector<int> v; int *p = NULL; //设置预留空间 v.reserve(100000); int num = 0; for (int i = 0; i < 阅读全文
posted @ 2021-04-27 16:12 lodger47 阅读(109) 评论(0) 推荐(0)
摘要: c++(vector 巧用swap收缩空间) 巧用swap收缩空间 void test01() { vector<int> v; for (int i = 0; i < 100000; i++) { v.push_back(i); } cout << "v的容量" << v.capacity() < 阅读全文
posted @ 2021-04-27 16:06 lodger47 阅读(235) 评论(0) 推荐(0)
上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 36 下一页

导航