Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Code snippet to replace all zeroes in a std::vector by a one.
#include <vector> #include <algorithm void ReplaceZeroByOne(std::vector<int>& v) { std::replace(v.begin(),v.end(),0,1); }