C++ examples for STL Algorithm:count
Counting Instances of a Value in a Sequence Using the count algorithm
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(int argc, char* argv[]) { vector<int> myVector{ 3, 2, 3, 7, 3, 8, 9, 3 }; auto number = count(myVector.begin(), myVector.end(), 3); cout << "The number of 3s in myVector is: " << number << endl; return 0;/*from www .ja va 2 s.com*/ }