Set

#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main()
{
cout<<"Hello World";
vector<int>b={1,3,4,0,1,8,10,-10,999,-9};
set<int>s;
for(int i=9;i>=0;--i){
s.insert(b[i]);
cout<<"******* "<<i<<endl;
for(auto it=s.begin();it!=s.end();++it)cout<<(*it)<<", adress is: "<<(&*it)<<",";
cout<<endl;
}
return 0;
}
Hello World*******  9
-9, adress is: 0x1ee7c70,
******* 8
-9, adress is: 0x1ee7c70,999, adress is: 0x1ee7ca0,
******* 7
-10, adress is: 0x1ee7cd0,-9, adress is: 0x1ee7c70,999, adress is: 0x1ee7ca0,
******* 6
-10, adress is: 0x1ee7cd0,-9, adress is: 0x1ee7c70,10, adress is: 0x1ee7d00,999, adress is: 0x1ee7ca0,
******* 5
-10, adress is: 0x1ee7cd0,-9, adress is: 0x1ee7c70,8, adress is: 0x1ee7d30,10, adress is: 0x1ee7d00,999, adress is: 0x1ee7ca0,
******* 4
-10, adress is: 0x1ee7cd0,-9, adress is: 0x1ee7c70,1, adress is: 0x1ee7d60,8, adress is: 0x1ee7d30,10, adress is: 0x1ee7d00,999, adress is: 0x1ee7ca0,
******* 3
-10, adress is: 0x1ee7cd0,-9, adress is: 0x1ee7c70,0, adress is: 0x1ee7d90,1, adress is: 0x1ee7d60,8, adress is: 0x1ee7d30,10, adress is: 0x1ee7d00,999, adress is: 0x1ee7ca0,
******* 2
-10, adress is: 0x1ee7cd0,-9, adress is: 0x1ee7c70,0, adress is: 0x1ee7d90,1, adress is: 0x1ee7d60,4, adress is: 0x1ee7dc0,8, adress is: 0x1ee7d30,10, adress is: 0x1ee7d00,999, adress is: 0x1ee7ca0,
******* 1
-10, adress is: 0x1ee7cd0,-9, adress is: 0x1ee7c70,0, adress is: 0x1ee7d90,1, adress is: 0x1ee7d60,3, adress is: 0x1ee7df0,4, adress is: 0x1ee7dc0,8, adress is: 0x1ee7d30,10, adress is: 0x1ee7d00,999, adress is: 0x1ee7ca0,
******* 0
-10, adress is: 0x1ee7cd0,-9, adress is: 0x1ee7c70,0, adress is: 0x1ee7d90,1, adress is: 0x1ee7d60,3, adress is: 0x1ee7df0,4, adress is: 0x1ee7dc0,8, adress is: 0x1ee7d30,10, adress is: 0x1ee7d00,999, adress is: 0x1ee7ca0,

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store