#include<iostream>
using namespace std;
#include "deque"
#include "algorithm" void printD(deque <int> &d)
{
for (deque<int>::iterator it = d.begin();it != d.end();it++)
{
cout<<*it<<endl;
}
}
void main41()
{
deque<int> d1;
//尾部放入三个元素
d1.push_back(1);
d1.push_back(3);
d1.push_back(5); d1.push_front(-11);
d1.push_front(-33);
d1.push_front(-55); cout<<"头部元素"<<d1.front()<<endl;
cout<<"尾部元素"<<d1.back()<<endl; printD(d1); d1.pop_front();
d1.pop_back();
printD(d1); //查找 -33在数组下标的值
deque<int>::iterator it = find(d1.begin(),d1.end(),-33);
if (it != d1.end())
{
cout<<"-33的数组下标是"<<distance(d1.begin(),it)<<endl;
}
else
{
cout<<"没有找到-33的元素"<<endl;
} }
void main()
{
main41();
cout<<"hello...\n"<<endl;
system("pause");
return;
}

C++STL学习笔记_(2)deque双端数组知识的更多相关文章

  1. C++STL学习笔记_(1)deque双端数组知识

    #include<iostream> using namespace std; #include "deque" #include "algorithm&qu ...

  2. C++STL学习笔记_(1)string知识

    /*============================================ string是STL的字符串类型,通常用来表示字符串 = ======================== ...

  3. C++STL学习笔记_(3)stack

    10.2.4stack容器 Stack简介 ²  stack是堆栈容器,是一种"先进后出"的容器. ²  stack是简单地装饰deque容器而成为另外的一种容器. ²  #inc ...

  4. C++STL学习笔记_(4)queue

    10.2.5Queue容器 Queue简介 ²  queue是队列容器,是一种"先进先出"的容器. ²  queue是简单地装饰deque容器而成为另外的一种容器. ²  #inc ...

  5. C++STL学习笔记_(1)vector知识

    #include<iostream> using namespace std; #include "vector" //数组元素的 添加和删除 void main31( ...

  6. Effective STL 学习笔记 Item 30: 保证目标区间足够大

    Effective STL 学习笔记 Item 30: 保证目标区间足够大 */--> div.org-src-container { font-size: 85%; font-family: ...

  7. jQuery源代码学习笔记_工具函数_noop/error/now/trim

    jQuery源代码学习笔记_工具函数_noop/error/now/trim jquery提供了一系列的工具函数,用于支持其运行,今天主要分析noop/error/now/trim这4个函数: 1.n ...

  8. STL学习系列三:Deque容器

    1.Deque简介 deque是“double-ended queue”的缩写,和vector一样都是STL的容器,deque是双端数组,而vector是单端的. deque在接口上和vector非常 ...

  9. Effective STL 学习笔记 39 ~ 41

    Effective STL 学习笔记 39 ~ 41 */--> div.org-src-container { font-size: 85%; font-family: monospace; ...

随机推荐

  1. 使用UICollectionView

    使用UICollectionView 使用UICollectionView的流程: 1. 设定一个UICollectionViewFlowLayout 2. 使用这个设定的UICollectionVi ...

  2. Office 365实现单点登录系列(3)—使用Azure AD Connect 进行目录同步

    Hello 小伙伴们,我回来了~ 2017年底中招了流感,还得了结膜炎,我也是无奈的···但使命感驱使我还是要把文章更完(这么敬业还不点赞关注(*^__^*) ) 我们接着上一篇文章继续说,上一篇已经 ...

  3. 铁乐学Python_day03-字符串常用操作方法

    文:铁乐与猫 2018-3-20 1)字符串首个字母大写,其它字母也会转换成小写: S.capitalize() -> str 记忆方法:capital(大写字母) def capitalize ...

  4. sharepoint 2013 service pack 和 Hotfix 版本

    方法1:Central Administration > System Settings > Manage servers in your farm (/_admin/FarmServer ...

  5. Memcached与Redis对比,Redis基础笔记回顾

    Memcached 1.为什么要把数据存入内存?快 2.Memcached和Redis的区别 (1)Memcached缓存.Redis数据库,Memcached不支持持久化到磁盘 (2)Redis提供 ...

  6. redis 配置文件redis.conf

    daemonize yes #---默认值no,该参数用于定制redis服务是否以守护模式运行.--- pidfile /var/run/redis.pid #默认值/var/run/redis.pi ...

  7. 在C#应用程序中,利用表值参数过滤重复,批量向数据库导入数据,并且返回重复数据

    在很多情况下,应用程序都需要实现excel数据导入功能,数据如果只有几十条,或上百条,甚至上千条,速度还好. 但是不仅如此,如果客户提供给你的excel本身存在着重复数据,或是excel中的某些数据已 ...

  8. 新手学Linux:在VMware14中安装CentOS7详细教程

    VMware Workstation14安装CentOS7.0 详情教程 1.准备工作 a)下载VMware workstation14 b)下载CentOS7 c)下载SSH Secure Shel ...

  9. Day1 Mybatis初识(一)

    框架 将重复的,繁琐的代码实现封装,让程序员将更多的精力放在业务的理解和分析上. 框架的作用 提高开发效率 隐藏细节 三大框架SSH  -->   SSM 1)        表述层:   用户 ...

  10. 1555: Inversion Sequence (通过逆序数复原序列 vector的骚操作!!!)

    1555: Inversion Sequence Submit Page    Summary    Time Limit: 2 Sec     Memory Limit: 256 Mb     Su ...