c++ find with predicat
#include <iostream>
#include <vector>
#include <algorithm>
bool isEven(int num) {
return num % 2 == 0;
}
int main() {
std::vector<int> numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
// Find the first even number using a predicate function
auto it = std::find_if(numbers.begin(), numbers.end(), isEven);
// Check if the element was found
if (it != numbers.end()) {
std::cout << "First even number found: " << *it << std::endl;
} else {
std::cout << "No even numbers found." << std::endl;
}
return 0;
}