fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <cmath>
  5.  
  6. int main() {
  7. std::vector<int> numbers = {-6, -7, 0, 4, 7, 1, 2, 21, -23, -2};
  8.  
  9. auto amount = std::count_if(numbers.begin(), numbers.end(),
  10. [](int value) { return abs(value) < 4; });
  11. std::cout << "Amount of numbers with abs less than 4 is " << amount;
  12. }
  13.  
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
Amount of numbers with abs less than 4 is 4