Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

count function vector c++

// CPP program to count vector elements that
// match given target value.
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
  
int main()
{
    vector<int> v{ 10, 30, 30, 10, 30, 30 };
    int target = 30;
    int res = count(v.begin(), v.end(), target);
    cout << "Target: " << target << " Count : " << res << endl;
    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #count #function #vector
ADD COMMENT
Topic
Name
3+9 =