fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. vector<int> x{ 1, 2, 3, 4, 5, 6, 7, 8 };
  9.  
  10. int numOdd = count_if(x.begin(), x.end(), [] (int in) {
  11. return in%2;
  12. });
  13.  
  14. std::cout<< "there were " << numOdd << " odd numbers" << std::endl;
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
there were 4 odd numbers