Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
replace_if-30-Seconds-of-C++
#include <iostream> #include <vector> #include <algorithm> int main() { auto isOdd = [](int i) { return ((i%2) == 1); }; std::vector<int> origin {1, 2, 3, 4, 5}; // replaces values for which isOdd returns true by 0 std::replace_if(origin.begin(), //first origin.end(), //last isOdd, //condition 0 //new_value ); // origin is now {0, 2, 0, 4, 0} for (auto value : origin) { std::cout << value << " "; } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
project euler problem - 3
Scope guarding
Web Browser History
IceCream
Anagrams WIP
break.cpp
POI
Boost phoenix. e.g 2: functor
tasks
queueArray
Please log in to post a comment.