Answers for "how to find a integer is how many times repeated in C++ without for loop"

C++
0

how to find a integer is how many times repeated in C++ without for loop

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
   vector<int> v = {1, 3, 3, 3, 3};
   int cnt;

   cnt = count(v.begin(), v.end(), 3);

   cout << "Number 3 occurs " << cnt << " times." << endl;

   return 0;
}
Posted by: Guest on April-20-2021

Code answers related to "how to find a integer is how many times repeated in C++ without for loop"

Browse Popular Code Answers by Language