0
点赞
收藏
分享

微信扫一扫

STL总结(不断补充)

狗啃月亮_Rachel 2022-02-09 阅读 73
数据结构

1.

lower_bound( begin,end,num):第一个大于等于num的数字

upper_bound( begin,end,num):第一个大于num的数字

lower_bound( begin,end,num,greater<type>() ):第一个小于或等于num的数字。

upper_bound( begin,end,num,greater<type>() ):第一个小于num的数字

找到返回该数字的地址,不存在则返回end

通过返回的地址减去起始地址begin,得到找到数字在数组中的下标(从0开始)

2.

删除重复元素
alls.erase(unique(alls.begin(),alls.end()),alls.end())

unique()返回第一个重复元素的地址

举报

相关推荐

0 条评论