STL数组处理常用函数
reverse(a,a+n)反转
sort(a,a+n,cmp)排序
unique(a,a+n,cmp)对于有序集合进行去重,返回新数组最后一个元素的指针
next_permutatoin(a,a+n,cmp)下一个排列
make_heap(a,a+n,cmp),sort_heap(a,a+n,cmp),pop_heap(a,a+n,cmp),push_heap(a,a+n,cmp)与堆有关的四个函数
上例中cmp表示自定义的比较函数
bool cmp(const Node&m,const Node&n);
用和堆有关的函数自定义优先队列
struct PreQ{
int a[qsz];
int sz;
void init(){
sz = ;
}
void enq(int x){
a[sz++] = x;
push_heap(a, a + sz);
}
int deq(){
pop_heap(a, a + sz);
return a[--sz];
}
}q;
STL数组处理常用函数的更多相关文章
- STL之vector常用函数笔记
STL之vector常用函数笔记 学会一些常用的vector就足够去刷acm的题了 ps:for(auto x:b) cout<<x<<" ";是基于范围的 ...
- php 数组的常用函数
在php教程中数组是种强大的数据类型,他可以做的事情很多,可以存储不同的数据类型在一个数组中,下面我们列出了数组常用的操作,排序,键名对数组排序等做法. /* 数组的常用函数 * * 数组的排序函 ...
- PHP数组的常用函数
在PHP中数组是种强大的数据类型,他可以做的事情很多,可以存储不同的数据类型在一个数组中,下面我们列出了数组常用的操作,排序,键名对数组排序等做法. /* 数组的常用函数 * * 数组的排序函数 ...
- 操作 numpy 数组的常用函数
操作 numpy 数组的常用函数 where 使用 where 函数能将索引掩码转换成索引位置: indices = where(mask) indices => (array([11, 12, ...
- 【STL】string 常用函数
string类的构造函数: string(const char *s); //用c字符串s初始化 string(int n,char c); //用n个字符c初始化 此外,string类还支持默认构造 ...
- php 指针遍历、预定义数组和常用函数
<?php /*//定义 $attr = array(1,2,3); $attr[] = 1; $attr = array("one"=>"hello&quo ...
- java数组的常用函数
import java.util.*; class 数组索引{ public static void main(String args[]){ //数组中的使用工具:Arrays int[] arr ...
- ruby中数组的常用函数
在程序中定义一个数组 在程序中定义一个数组,因为我们在下面说明. fruits = ["apple", "orange", "lemon"] ...
- 「STL中的常用函数 容器」
占个坑,下午在更 二分操作:lower_bound和upper_bound 存图/数列操作:vector容器 全排列:next_permutation和prev_permutation 字符串转数列: ...
随机推荐
- 王总QQ聊天对话
在吗? LeeYu 2015/11/10 9:37:11 在的,王总 王宁 2015/11/10 9:37:29 李伟,你今天把设备送到H3C吧. LeeYu 2015/11/10 9:37:43 行 ...
- C# .NET 动态调用webservice的三种方式
转载自 百度文库 http://wenku.baidu.com/link?url=Q2q50wohf5W6UX44zqotXFEe_XOMaib4UtI3BigaNwipOHKNETloMF4ax4W ...
- monkeyrunner之环境搭建及实例(三)
Monkeyrunner工具提供了一个API,使用此API写出的程序可以在Android代码之外控制Android设备和模拟器. 一.Monkeyrunner简介 1.MOnkeyrunner相对Mo ...
- background-position百分比原理
今天帮别人调代码时,看到一个样式: background-position: 50% 0;background-size: 100% auto: 对background-size:100% auto, ...
- GTAC 2015 Schedule
之前发的GTAC 2015将于11月10号和11号召开 现在时刻表也出来啦 https://developers.google.com/google-test-automation-conferenc ...
- [转]mysql 乱码问题解决终结
http://www.th7.cn/db/mysql/2011-07-07/9217.shtml 查看 MYSQL的字符设置,在SQL查询界面输入 SHOW VARIABLES LIKE 'chara ...
- [No000015]坏习惯一大堆?别怕,还有救-坏习惯一堆,怎么好好学习嘛!
- 转: VMware 安装mac osx 10.11 安装步骤(一)(from伟东)
http://blog.csdn.net/soachenshui/article/details/49251513
- sql语句常用说明与解析
from: http://www.cnblogs.com/rainman/archive/2013/05/01/3053703.html#m3
- UIButton(改变Title和image位置)
UIButton *btn = [[UIButton alloc] init]; [btn setFrame:frame]; [btn setTitleColor:titleColor forStat ...