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
NonparaU
BinTree
typedef
Working variables benchmark
Algoritm(prelucrare cifre)
Stock buy/sell
Pointer to class members
Queue with Limited Size of Arrays
Bad code
Programa 3(Creo que ya esta)