#include #include #include #include #include
template< typename _T1, typename _T2 = int >void print(_T1 & data){ std::copy(data.begin(), data.end(), std::ostream_iterator< _T2 >(std::cout, " ")); std::cout << std::endl;}<br>template< typename T>void replace_sign(T begin, T end){ for (T iter = begin; iter != end; iter++) { if (*iter <= 0) *iter = 0; else *iter = 1; }}<br>int main(void){ std::vector< int > data = {-2, 2, 0, 9 -5, 8, 0, 10, -8}; print(data); replace_sign(data.begin(), data.end()); print(data);
return 0;}