Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
set<int> s; //Declaring an empty set container
set<int>::iterator iter; //Declaring a set container as iterator which will point to the lower bound value
s.insert(7); //inserting elements in the set container s
s.insert(6);
s.insert(1);
s.insert(4);
s.insert(2);
s.insert(9);
s.insert(10);
iter = s.lower_bound(4); //passing a key by parameter to find its lower bound
cout <<"The lower bound of 4 is: "<< *iter << " "<<endl; //printing the lowerbound value
iter = s.lower_bound(5);
cout <<"The lower bound of 5 is: " <<*iter << " "<<endl;
iter = s.lower_bound(30);
cout <<"The lower bound of 30 is: " <<*iter << " "<<endl;
return 0;
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more