Last active
September 12, 2018 08:00
-
-
Save mochow13/b2954dcf1f95a2ccfb064fce7ba5b885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<int> collection={1,9,9,4,2,6}; | |
// How many 9s are there in collection? | |
int nines=std::count(begin(collection),end(collection),9); | |
// How many elements of the collection are even? | |
int evens=std::count_if(begin(collection),end(collection),[](int x) { | |
return x%2==0; | |
}); | |
// nines equals 2, evens equals 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment