阅读读程序(3)
来源:互联网 发布:发那科机器人编程培训 编辑:程序博客网 时间:2024/05/17 23:51
*All right reserved.
*文件名称:test.cpp
*作 者:韩双志
*完成日期:2016年6月16日
*版本号:v1.0
*
*问题描述:multiset用法
*输入描述:无
*输出描述:输出相应的结果
/*
#include <algorithm>
#include<set>
#include<iterator>
#include<iostream>
using namespace std;
int main()
{
multiset<int>eg1;
//插入
eg1.insert(1);
eg1.insert(100);
eg1.insert(5);
eg1.insert(1);//是否插入
eg1.insert(10);
eg1.insert(9);
//遍历set,可以发现元素是有序的
multiset<int>::iterator set_iter=eg1.begin();
cout<<"Set named eg1:"<<endl;
for(; set_iter!=eg1.end(); set_iter++)
cout<<*set_iter<<" ";
cout<<endl;
//使用size()函数可以获得当前元素个数
cout<<"Now there are "<<eg1.size()<<" elements in the set eg1"<<endl;
if(eg1.find(200)==eg1.end())//find()函数可以查找元素是否存在
cout<<"200 isn't in the set eg1"<<endl;
return 0;
}
*/
运行结果:
知识点总结
multiset是<set>库中一个非常有用的类型,它可以看成一个序列,插入一个数,删除一个数都能够在O(logn)的时间内完成,而且他能时刻保证序列中的数是有序的,而且序列中可以存在重复的数
- 阅读读程序(3)
- 阅读程序(3)
- 阅读程序(3)
- 阅读程序(3)
- 阅读程序(3)(4)
- 第十四周阅读程序:1-(3)
- 第二周 阅读程序 (3)
- 第三周:程序阅读(3)
- 第三周阅读程序 (3)
- 第四周 阅读程序(3)
- 第四周阅读程序 (3)
- 第五周程序阅读(3)
- 第四周程序阅读(3)
- 第五周 阅读程序(3)
- 第五周 阅读程序(3)
- 第六周 阅读程序(3)
- 第六周阅读程序 (3)
- 第六周 阅读程序 (3)
- ACCESS数据库转ORACLE数据库
- Linux中,使用cron,按照日期日志,并且删除n天以前的日志归档
- Android animation开发笔记
- django全貌
- 第三篇博客
- 阅读读程序(3)
- AsyncSocket
- mysql 出现column not found 问题
- 虚拟存储器
- 单链表的逆置(完整程序加思路分析)
- 基于Android Studio的内存泄漏检测与解决全攻略
- gulpfile
- MVC,MVP 和 MVVM 的图示
- android系统中与内存有关的文件及路径