This is the answer of Exercise #9: No for-loops.
Question #15: write to std::cout
Replace the for-loop. You will need:
#include <vector> void CoutVector(std::vector<int>& v) { const int sz = static_cast<int>(v.size()); for (int i=0; i!=sz; ++i) { std::cout << v[i] << '\n'; } }
#include <iostream> #include <iterator> #include <ostream> #include <vector> //From http://www.richelbilderbeek.nl/CppCoutVector.htm template <class T> void CoutVector(const std::vector<T>& v) { std::copy(v.begin(),v.end(),std::ostream_iterator<T>(std::cout,"\n")); }