随笔分类 -  C++语言相关

摘要:在c++中,vector是一个十分有用的容器。 作用:它能够像容器一样存放各种类型的对象,简单地说,vector是一个能够存放任意类型的动态数组,能够增加和压缩数据。 vector在C++标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库。 特别注意: 使用vect 阅读全文
posted @ 2022-03-25 17:35 liuyongliu 阅读(29) 评论(0) 推荐(0) 编辑
摘要:memset是刷内存用的,一次刷一个字节,而且速度超级快。 如:memset(a,1,sizeof(a)); 运行后a数组中元素的值(int型,四个字节) 因此得到的答案是 结论:memset只能用于清零或清为-1(可以自行证明) 测试代码: 阅读全文
posted @ 2019-01-28 15:49 liuyongliu 阅读(1684) 评论(3) 推荐(0) 编辑
摘要:「笔记」读入优化 终极模板: 1 #include<cstdio> 2 class Read 3 { 4 private: 5 inline char getc() 6 { 7 static char buf[1<<18], *fs, *fe; 8 return (fs == fe && (fe = 阅读全文
posted @ 2019-01-25 17:06 liuyongliu 阅读(223) 评论(0) 推荐(0) 编辑
摘要:c++优先队列(priority_queue)用法详解 //升序队列 priority_queue <int,vector<int>,greater<int> > q; //降序队列 priority_queue <int,vector<int>,less<int> >q; //greater和le 阅读全文
posted @ 2019-01-25 16:42 liuyongliu 阅读(176) 评论(0) 推荐(0) 编辑
摘要:参考博客:STL nth_element神器 官方解释:http://www.cplusplus.com/reference/algorithm/nth_element/ nth_element(first,nth,last) 即寻找数组中由小到大排在第n的元素,放在第n个位置上(假设下标从1开始) 阅读全文
posted @ 2019-01-24 21:26 liuyongliu 阅读(398) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示