关联容器1

#include<set>
#include<iterator>
#include<utility>
#include<iostream>
using namespace std;
int main()
{
set<double>s;
while(true){
double v;
cin>>v;
if(v==0) break;
auto r=s.insert(v);
if(!r.second)
cout<<v<<" is duplicated"<<endl;
}
auto iter1=s.begin();
auto iter2=s.end();
double medium=(* iter1+*(--iter2))/2;
cout<<"<=medium: ";
copy(s.begin(), s.upper_bound(medium), ostream_iterator<double>(cout," "));
cout<<endl;
cout<<">=medium: ";
copy( s.lower_bound(medium), s.end(), ostream_iterator<double>(cout,""));
cout<<endl;
return 0;
}

posted @ 2023-05-05 20:08  不会JAVA的小袁  阅读(11)  评论(0编辑  收藏  举报