Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. vector<int> v = {9, 2, 5, 1};
  2. auto isEven = [](const int& a){ return a % 2 == 0; };
  3. cout << (any_of(v.begin(), v.end(), isEven) ? "Yes\n" : "No\n"); //outputs: Yes
  4.  
  5. v = {9, 3, 5, 1};
  6. cout << (any_of(v.begin(), v.end(), isEven) ? "Yes\n" : "No\n"); // outputs: No
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement