C++ STL partial_sort_copy
#include <iostream>
#include <deque>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
deque<int> deq1;
deque<int>::iterator deq_iter1;
vector<int> vec1(15);
for (int k=0;k<15;k++)
{
deq1.push_back(rand());
}
for (deq_iter1 = deq1.begin();deq_iter1 != deq1.end();++deq_iter1)
{
cout << *deq_iter1 << " ";
}
cout << endl;
cout << "----------------------------------" << endl;
partial_sort(deq1.begin(), deq1.begin() + 5, deq1.end());
for (deq_iter1 = deq1.begin(); deq_iter1 != deq1.end(); ++deq_iter1)
{
cout << *deq_iter1 << " ";
}
cout << endl;
cout << "----------------------------------" << endl;
random_shuffle(deq1.begin(), deq1.end());
partial_sort_copy(deq1.begin(), deq1.end(), vec1.begin(), vec1.end());
vector<int>::iterator vec_iter1;
for (vec_iter1 = vec1.begin();vec_iter1 != vec1.end();++vec_iter1)
{
cout << *vec_iter1 << " ";
}
cout << endl;
system("pause");
return 0;
}
=================================================
41 18467 6334 26500 19169 15724 11478 29358 26962 24464 5705 28145 23281 16827 9961
----------------------------------
41 5705 6334 9961 11478 26500 19169 29358 26962 24464 18467 28145 23281 16827 15724
----------------------------------
41 5705 6334 9961 11478 15724 16827 18467 19169 23281 24464 26500 26962 28145 29358
请按任意键继续. . .
C++ STL partial_sort_copy的更多相关文章
- C++ STL partial_sort_copy iterator
vector<int>::iterator iter1 = partial_sort_copy(deq1.begin(), deq1.end(), vec1.begin(), vec1.e ...
- C++ STL partial_sort_copy greater
#include <iostream>#include <deque>#include <algorithm>#include <vector>#inc ...
- STL 源代码剖析 算法 stl_algo.h -- partial_sort / partial_sort_copy
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie partial_sort / partial_sort_copy ------------- ...
- 详细解说 STL 排序(Sort)
0 前言: STL,为什么你必须掌握 对于程序员来说,数据结构是必修的一门课.从查找到排序,从链表到二叉树,几乎所有的算法和原理都需要理解,理解不了也要死记硬背下来.幸运的是这些理论都已经比较成熟,算 ...
- C++的STL
今天,看一段代码的时候发现只一句话就做了个排序,是这样的: sort(rotateArray.begin(),rotateArray.end()); 很震惊,后来查了一下sort的用法, sort函数 ...
- stl 比较和boost LessThanComparable
C++ STL的几种常用“比较”概念简述 在C++的现行标准(C++ 98)中,由于没有类似“接口”这样的东西,我们在泛型编程时往往只能对模板类型作一些假设,要求其符合某个需求清单,也就是属于某个 ...
- c++中级 STL基础学习(二)
deque 和vector差不多,可以在前端后端插入,一般用deque取代vector,vector只能在后端插入push_back().deque还可以push_front(),但是deque后端插 ...
- STL学习之路
本文面向的读者:学习过C++程序设计语言(也就是说学习过Template),但是还没有接触过STL的STL的初学者.这实际上是我学习STL的一篇笔记,老鸟就不用看了. 什么是泛型程序设计 我们可以简单 ...
- STL中的算法小结
()要运用STL的算法,首先必须包含头文件<algorithm>,某些STL算法用于数值处理,因此被定义于头文件<numeric> ()所有STL算法都被设计用来处理一个或多个 ...
随机推荐
- 13 Windows编程——系统内置窗口子类型之静态子窗口
静态子窗口类型 wndclass:static 源码 #include<Windows.h> #include<Windowsx.h> HINSTANCE G_h; LRESU ...
- centos7防火墙相关
selinux(保护文件安全) 安全增强型 Linux(Security-Enhanced Linux)简称 SELinux,它是一个 Linux 内核模块,也是 Linux 的一个安全子系统. SE ...
- Paper Reading:Mask RCNN
Mask RCNN 论文:Mask R-CNN 发表时间:2018 发表作者:(Facebook AI Research)Kaiming He, Georgia Gkioxari, Piotr Dol ...
- gitlab-ce白名单设置杜绝并发数过大引起的封ip故障
gitlab-ce 7.9安装手札以及上篇文章的问题解决 鸣谢 感谢ruby大神===>章鱼的一路指点,才能拨开迷雾见云天! 章鱼大人: 国内Ansible部落原创翻译之一! 资深运维! ROR ...
- Python 字节码bytecode
字节码bytecode python把源码文件编译成字节码文件,存放在__pycahe子目录内,用.pyc结尾.之后如果不再修改源码文件,运行时则使用*.pyc文件编译成机器码,这样不但运行速度快,而 ...
- TFTP简单文件传送协议
T F T P ( Trivial File Transfer Protocol)即简单文件传送协议,最初打算用于引导无盘系统(通常是工作站或X终端).和将在介绍的使用T C P的文件传送协议(F T ...
- 2018 南京网络预赛Sum - 线性筛
题意 链接 定义 $f(x)$ 为满足以下条件的有序二元组 $(a, b)$ 的方案数(即 $(a, b)$ 与 $(b, a)$ 被认为是不同的方案): $x= ab$ $a$ 和 $b$ 均无平方 ...
- 一个简单易上手的短信服务Spring Boot Starter
前言 短信服务在用户注册.登录.找回密码等相关操作中,可以让用户使用更加便捷,越来越多的公司都采用短信验证的方式让用户进行操作,从而提高用户的实用性. Spring Boot Starter 由于 S ...
- 2、Spring Boot 2.x 快速入门
1.2 Spring Boot 快速入门 1.2.1 开发环境和工具 JDK 1.8+:Spring Boot 2.x 要求 JDK 1.8 环境及以上版本.另外,Spring Boot 2.x 只兼 ...
- E:last-child
E:last-child 语法: E:last-child { sRules } 说明: 匹配父元素的最后一个子元素E.大理石平台厂家大理石平台厂家 要使该属性生效,E元素必须是某个元素的子元素,E的 ...