count
#include <bits/stdc++.h>using namespace std;int main(){int arr[] = { 14, 12, 15, 11, 10 };// initializes the set from an arrayset<int> s(arr, arr + 5);// check if 11 is present or notif (s.count(11))cout << "11 is present in the set\n";elsecout << "11 is not present in the set\n";// checks if 18 is present or notif (s.count(18))cout << "18 is present in the set\n";elsecout << "18 is not present in the set\n";return 0;}
输出:
11 is present in the set
18 is not present in the set
