fork download
  1. #include <iostream>
  2. #include <set>
  3.  
  4. int main() {
  5. // Create a set object holding integers
  6. std::set<int> mySet {1, 2, 3, 4, -5};
  7.  
  8. if (mySet.find(1) != mySet.end()) {
  9. std::cout << "1 : is a element of mySet" << std::endl;
  10. } else {
  11. std::cout << "1 : is not an element of myset" << std::endl;
  12. }
  13.  
  14. if (mySet.find(12) != mySet.end()) {
  15. std::cout << "12 : is a element of mySet" << std::endl;
  16. } else {
  17. std::cout << "12 : is not an element of myset" << std::endl;
  18. }
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 4348KB
stdin
Standard input is empty
stdout
1 : is a element of mySet
12 : is not an element of myset