Run Code
|
API
|
Code Wall
|
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
Widget Class with dynamic memory and pointers
Default_Template
Simple use of function templete and namespace
decode
PalindromeDay
New wall
Random Vector Generator
Stack
for.cc
Aiutttt