stl学习
文章平均质量分 83
SDNUlixianrui
这个作者很懒,什么都没留下…
展开
-
stl学习—set
参考博客http://blog.csdn.net/ac_hexin/article/details/52042562set集合容器实现了红黑树(Red-Black Tree)的平衡二叉检索树的的数据结构,在插入元素时,它会自动调整二叉树的排列,把该元素放到适当的位置,以确保每个子树根节点的键值大于左子树所有节点的键值,而小于右子树所有节点的键值;另外,还得确保根节点的左子树的高度与有字数的高度原创 2017-12-05 11:19:27 · 140 阅读 · 0 评论 -
next_permutation函数(全排列生成利器)
题目大意:给出一个n和一个m,要求求出数列1,2,3……nNow our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the BEelzebub has to beat our h原创 2017-12-04 17:40:39 · 218 阅读 · 0 评论 -
c++ stl学习—优先队列
优先队列(priority queue) 普通的队列是一种先进先出的数据结构,元素在队列尾追加,而从队列头删除。在优先队列中,元素被赋予优先级。当访问元素时,具有最高优先级的元素最先删除。优先队列具有最高级先出 (largest-in,first-out)的行为特征。STL中的优先队列-priorit_queue,包含在头文件”queue”中,可以使用具有默认优先级的已有数据结构;也可原创 2017-11-28 11:11:02 · 7169 阅读 · 1 评论 -
stl学习——map
map的排序功能:map插入:mapq; q.insert(pair(1,"li"));q[1] = "li";第一种方法插入的话,会出现插入不成功的情况,即key相同的时候,后插入的,插不进去。而第二种方法插入的话,出现key相同时,后插入的会把前面插入的value进行覆盖。map的大小q.size(),返回值为map的大小map的迭代:1(原创 2017-11-27 12:20:05 · 164 阅读 · 0 评论 -
c++11 auto 遍历map,vector
#include #include #include using namespace std;int main(){ map student; student.insert(pair(2,"li")); student.insert(pair(1,"wang")); student.insert(pair(3,"sun")); for(auto原创 2017-11-24 20:04:20 · 61008 阅读 · 1 评论 -
vector 多维向量定义及其初始化
using namespace std;一维向量:vectorint> vector_1D_1;//只定义向量vectorint> vector_1D_2(n);//定义的同时初始化大小vectorint> vector_1D_3(n,m);//定义的同时初始化大小为n,元素初始值为mvectorint> vector_1D_4;vector_1D_4=vectorint>(n转载 2017-12-14 18:56:49 · 10418 阅读 · 0 评论 -
UVA 10474 - Where is the Marble?( 利用stl函数lower_bound)
Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beginning, Raju would place the marbles one after another in ascending order of the number原创 2018-01-18 20:41:10 · 388 阅读 · 0 评论