Created
September 18, 2018 15:23
-
-
Save mochow13/9310ab92a885321e79ca44f5f2591277 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={6,5,3,2,1,4,6,7}; | |
std::vector<int> sums, mults; | |
// contains the partial sum of collection in result | |
std::partial_sum(begin(collection), end(collection), std::back_inserter(sums)); | |
// contains the partial product | |
std::partial_sum(begin(collection), end(collection), std::back_inserter(mults), std::multiplies<int>()); | |
// you can also use your own binary operation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment