顺序容器删除元素 vector list deque
#include <iostream>
#include <list>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
list<string> slist;
slist.push_back("A");
slist.push_back("B");
slist.push_back("C");
slist.push_back("D");
slist.push_back("E");
slist.push_back("F");
slist.push_back("G");
list<string>::iterator iter;
for (iter=slist.begin();iter != slist.end();++iter)
{
cout << *iter<< endl;
}
cout << "---------------------------------------" << endl;
string s1("D");
string s2("F");
list<string>::iterator iter_start = find(slist.begin(),slist.end(),s1);
list<string>::iterator iter_end = find(slist.begin(), slist.end(), s2);
if (iter_start != slist.end() && iter_end != slist.end())
{
slist.erase(iter_start,iter_end);
}
cout << "---------------------------------------" << endl;
list<string>::iterator iter2;
for (iter2 = slist.begin(); iter2 != slist.end(); ++iter2)
{
cout << *iter2 << endl;
}
cout << "---------------------------------------" << endl;
system("pause");
return 0;
}
=======================================================
A
B
C
D
E
F
G
---------------------------------------
---------------------------------------
A
B
C
F
G
---------------------------------------
请按任意键继续. . .
最新文章
- 命名空间“System.Web”中不存在类型或命名空间名称“Optimization”(是否缺少程序集引用?)
- 自然语言处理3.3——使用Unicode进行文字处理
- (转)根据IP返回对应的位置信息
- ConcurrentHashMap中的2的n次方幂上舍入方法(转)
- java学习笔记 --- 抽象类
- Git错误一例
- jdk各个版本之间的差异
- BZOJ 5261 Rhyme
- 论文笔记系列-Speeding Up Automatic Hyperparameter Optimization of Deep Neural Networks by Extrapolation of Learning Curves
- JMeter中BeanShell断言使用一
- servlet 最大线程数探索笔记
- 基于SSH实现员工管理系统之框架整合篇
- 计时器setInterval()
- C语言复习:结构体
- Beta阶段第五篇Scrum冲刺博客-Day4
- MariaDB 视图与触发器(11)
- Tracing 在PeopleSoft 程序中怎么开启
- Hadoop分布式远程Debug方式
- angularjs中audio/video 路径赋值问题
- java 数据结构与算法---递归
热门文章
- Visual studio 2010 打开高版本VS工程解决办法
- python-----多线程笔记
- 成功解决 AttributeError: module &#39;tensorflow.python.keras.backend&#39; has no attribute &#39;get_graph&#39;
- React 新特性学习
- input 设置 display:none后 jquery无法给input赋值
- bug提交遵循的规则
- [2019HDU多校第二场][HDU 6591][A. Another Chess Problem]
- 常见http响应状态码(status)
- 使用Ajax向SpringMVC传递Json数据
- Python3读写JSON文件