fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. // this repeats the entry in set, dont know how to overcome this???
  4. struct f{
  5. bool operator()( int a, int b){
  6. return a<b;
  7. }
  8. };
  9. int main() {
  10. set<int,f> s;
  11. s.insert(2);
  12. s.insert(1);
  13. s.insert(3);
  14. s.insert(2);
  15. cout<<s.size()<<"\n";
  16. for(auto x: s) cout<<x<<" ";
  17. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
3
1 2 3