How to check if a set contain specific value or not in C++

1 Answer

0 votes
#include <iostream>       
#include <set> 
         
using namespace std; 
  
int main ()
{
    set<int> st;
    
    st.insert(1); 
    st.insert(9); 
    st.insert(7); 
    st.insert(3); 
    st.insert(1); 
    st.insert(7);
    st.insert(1);
      
    cout << st.count(7) << endl;
    cout << st.count(4);
     
    return 0;
} 
     
  
     
     
/*
run:
     
1
0
  
*/

 



answered Apr 7, 2020 by avibootz
edited Apr 7, 2020 by avibootz
...