#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
  vector<int> vec1;
  deque<int> deq1;

  for (int k=0;k<10;k++)
  {
    vec1.push_back(k);
  }

  for (int k=10;k<23;k++)
  {
    deq1.push_back(k);
  }

  for (auto vec_iter1 = vec1.begin();vec_iter1 != vec1.end();++vec_iter1)
  {
    cout << *vec_iter1 << " ";
  }
  cout << endl;
  cout << "------------------------------------------------------------" << endl;

  for (auto vec_iter1 = deq1.begin(); vec_iter1 != deq1.end(); ++vec_iter1)
  {
    cout << *vec_iter1 << " ";
  }
  cout << endl;
  cout << "------------------------------------------------------------" << endl;

  swap_ranges(vec1.begin(), vec1.end(), deq1.begin());

  for (auto vec_iter1 = vec1.begin(); vec_iter1 != vec1.end(); ++vec_iter1)
  {
    cout << *vec_iter1 << " ";
  }
  cout << endl;
  cout << "------------------------------------------------------------" << endl;

  for (auto vec_iter1 = deq1.begin(); vec_iter1 != deq1.end(); ++vec_iter1)
  {
    cout << *vec_iter1 << " ";
  }
  cout << endl;
  cout << "------------------------------------------------------------" << endl;

  system("pause");
  return 0;
}

================================================================

0 1 2 3 4 5 6 7 8 9
------------------------------------------------------------
10 11 12 13 14 15 16 17 18 19 20 21 22
------------------------------------------------------------
10 11 12 13 14 15 16 17 18 19
------------------------------------------------------------
0 1 2 3 4 5 6 7 8 9 20 21 22
------------------------------------------------------------
请按任意键继续. . .

C++ STL swap_range的更多相关文章

  1. C++的STL

    今天,看一段代码的时候发现只一句话就做了个排序,是这样的: sort(rotateArray.begin(),rotateArray.end()); 很震惊,后来查了一下sort的用法, sort函数 ...

  2. STL学习小结

    STL就是Standard Template Library,标准模板库.这可能是一个历史上最令人兴奋的工具的最无聊的术语.从根本上说,STL是一些"容器"的集合,这些" ...

  3. STL算法

    STL算法部分主要由头文 件<algorithm>,<numeric>,<functional>组成.要使用 STL中的算法函数必须包含头文件<algorit ...

  4. C++ STL 一般总结

    以下内容来源网上 经过整合而成(转载) 一.一般介绍 STL(Standard Template Library),即标准模板库,是一个具有工业强度的,高效的C++程序库.它被容纳于C++标准程序库( ...

  5. STL中的所有算法(70个)

    STL中的所有算法(70个)----9种类型(略有修改by crazyhacking) 参考自: http://www.cppblog.com/mzty/archive/2007/03/14/1981 ...

  6. C++之STL总结精华笔记

                       一.一般介绍      STL(StandardTemplate Library),即标准模板库,是一个具有工业强度的,高效的C++程序库.它被容纳于C++标准程 ...

  7. C++复习:STL之算法

    算法 1算法基础 1.1算法概述 算法部分主要由头文件<algorithm>,<numeric>和<functional>组成. <algorithm> ...

  8. C++STL 算法

    算法部分主要由头文件<algorithm>,<numeric>和<functional>组成. <algorithm>是所有STL头文件中最大的一个,其 ...

  9. C++ STL 整理

    一.一般介绍 STL(Standard Template Library),即标准模板库,是一个具有工业强度的,高效的C++程序库.它被容纳于C++标准程序库(C++ Standard Library ...

随机推荐

  1. java - day010 - 基本类型包装,自动装箱和拆箱,日期,集合

    基本类型的包装类 byte Byte short Short int Integer long Long float Float double Double char Character boolea ...

  2. B-Tree目录和Hash索引的区别

    Hash 索引结构的特殊性,其检索效率非常高,索引的检索可以一次定位,不像B-Tree 索引需要从根节点到枝节点,最后才能访问到页节点这样多次的IO访问,所以 Hash 索引的查询效率要远高于 B-T ...

  3. 2018年5月20日--西安icpc邀请赛打铁总结

    2018年5月20日--西安icpc邀请赛打铁总结  事后诸葛亮 大致回顾一下比赛,29号的热身赛和30号的正式赛. 热身赛总共三道题,一个小时,没有AC一道题目. A题是一个几何题目,审题时犯了一个 ...

  4. SQL SERVER 查询第20行到30之间的数据

    1.先查询前20行的ID,后查询除去20条记录的前10条记录 SELECT TOP * FROM tbBank WHERE BankID NOT IN(SELECT TOP BankID FROM t ...

  5. Ellipsis对象

    Ellipsis对象. 写作 : ‘…’ 中文解释:省略 该对象bool测试是为真 用途: 1.用来省略代码,作用类似于pass的一种替代方案,这是python的’TBD’(未确定内容). def f ...

  6. Spark1

    Spark集群 0.0体验安装Spark在集群单节点 1.tar tar -xzvf xxx.tgz -C /soft/ ln -s /soft/spark-2.1.0-bin-hadoop2.7 / ...

  7. Python 10.1

  8. mousemove([[data],fn])

    mousemove([[data],fn]) 概述 当鼠标指针在指定的元素中移动时,就会发生 mousemove 事件.大理石构件来图加工 mousemove事件处理函数会被传递一个变量——事件对象, ...

  9. C/C++应用--Window下获取硬件信息(CPU, 硬盘,网卡等)

    一.头文件如下: #include <Windows.h> #include <string> #include <iostream> #include <w ...

  10. 题解 CF550A 【Two Substrings】

    为什么我的做法跟别人如此不一样啊qwq 思路:暴力判每一个"BA"出现的位置,二分查找他前/后有没有满足条件的"AB",时间复杂度\(O(n\log_{2}n) ...