#include <iostream>
#include <set>
#include <string>
#include <iterator>
#include <algorithm>
#include "TestSet.h"
using namespace std;
void TestSet()
{
double a[5]={4.4,2.2,5.5,3.3,16.6};
set<double,less<double>>doubleSet(a,a+5);
cout<<"doubleSet contains: ";
copy(doubleSet.begin(),doubleSet.end(),ostream_iterator<double>(cout," "));
cout<<endl;
pair<set<double,less<double>>::const_iterator,bool>p;
p=doubleSet.insert(13.8);
cout<<(*p.first)<<(p.second?"was":"was not")<<"inserted"<<endl;
cout<<"doubleSet contains: ";
copy(doubleSet.begin(),doubleSet.end(),ostream_iterator<double>(cout," "));
cout<<endl;
p=doubleSet.insert(5.5);
cout<<(*p.first)<<(p.second?"was":"was not")<<"inserted"<<endl;
cout<<"doubleSet contains: ";
copy(doubleSet.begin(),doubleSet.end(),ostream_iterator<double>(cout," "));
cout<<endl;
cout<<"lower_bound(3.5): "<<*doubleSet.lower_bound(3.5)<<endl;
cout<<"upper_bound(3.5): "<<*doubleSet.upper_bound(3.5)<<endl;
cout<<"equal_range(3.5): "<<*doubleSet.equal_range(3.5).first<<" "<<*doubleSet.equal_range(3.5).second<<endl;
cout<<"lower_bound(9.5): "<<*doubleSet.lower_bound(9.5)<<endl;
cout<<"upper_bound(9.5): "<<*doubleSet.upper_bound(9.5)<<endl;
cout<<"equal_range(9.5): "<<*doubleSet.equal_range(9.5).first<<" "<<*doubleSet.equal_range(9.5).second<<endl;
}
STL.rar_stl queue
版权申诉
165 浏览量
2022-09-21
18:08:50
上传
评论
收藏 4KB RAR 举报
weixin_42651887
- 粉丝: 75
- 资源: 1万+
最新资源
- xyctf:从入门到精通的实用指南.zip
- mmqrcode1714153659780.png
- Screenshot_2024-04-27-06-08-58-486_com.baidu.xin.aiqicha.jpg
- 基于Javaweb+Tomcat+MySQL的大学生公寓管理系统+sql文件.zip
- 实训作业基于javaweb的订单管理系统源码+数据库+实训报告.zip
- 多机调度问题贪心算法基于最小堆和贪心算法求解多机调度问题.zip
- 基于同态加密技术的匿名电子投票系统源码.zip
- Pyqt5项目框架-PyQt项目开发实践
- 基于C通过MQTT的智能农业大棚管理系统(本科毕业设计)
- python+CNN的网络入侵检测算法源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈