Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) ReplaceZeroByOne

 

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);
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict