zoukankan      html  css  js  c++  java
  • vector swap

    #include <iostream>
    #include <vector>
    #include <list>
    #include <deque>


    using namespace std;


    int main()
    {
      vector<int> a;
      vector<int> b;

      a.push_back(10);
      a.push_back(20);
      a.push_back(30);
      a.push_back(40);

      b.push_back(100);
      b.push_back(200);
      b.push_back(300);


      vector<int>::iterator a_iter;
      vector<int>::iterator b_iter;

      for (a_iter =a.begin();a_iter !=a.end();a_iter++)
      {
        cout << *a_iter<< endl;
      }
      cout << "-------------------------------" << endl;
      for (b_iter = b.begin(); b_iter != b.end(); b_iter++)
      {
        cout << *b_iter << endl;
      }

      cout << "-------------------------------" << endl;
      a.swap(b);


      vector<int>::iterator a_iter2;
      vector<int>::iterator b_iter2;

      for (a_iter2 = a.begin(); a_iter2 != a.end(); a_iter2++)
      {
        cout << *a_iter2 << endl;
      }
      cout << "-------------------------------" << endl;
      for (b_iter2 = b.begin(); b_iter2 != b.end(); b_iter2++)
      {
        cout << *b_iter2 << endl;
      }

      cout << "-------------------------------" << endl;


      system("pause");
      return 0;
    }

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

    10
    20
    30
    40
    -------------------------------
    100
    200
    300
    -------------------------------
    100
    200
    300
    -------------------------------
    10
    20
    30
    40
    -------------------------------
    请按任意键继续. . .

  • 相关阅读:
    jmeter测试mysql数据库之JDBC请求
    接口测试浅谈
    python import xxx 与 from xxx import xx 模块引入的区别
    交互模式下测试python代码及变量的四则运算
    python入门之一python安装及程序运行
    zabbix命令之:zabbix_get命令
    snmpwalk工具使用
    zabbix基础知识
    Centos7.5 rpm安装zabbix_agent4.0.3
    mysql常用命令
  • 原文地址:https://www.cnblogs.com/herd/p/10993817.html
Copyright © 2011-2022 走看看