fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iterator>
  4. using namespace std;
  5. int main()
  6. {
  7. int array[]= {1,1,2,3,4,1,3,2,9,8,7};
  8. int num = 1;
  9. unsigned int cnt = count(begin(array), end(array), num);
  10. cout << "The number " << num << " appears " << cnt << " times\n";
  11. }
  12.  
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
The number 1 appears 3 times