#include <algorithm
#include <iostream>
#include <iterator>
int main()
{
std::vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
v.push_back(4);
v.push_back(5);
v.push_back(6);
v.push_back(7);
v.push_back(8);
v.push_back(9);
std::vector<int> from;
from.push_back(2);
from.push_back(3);
from.push_back(4);
std::vector<int> to;
to.push_back(1);
to.push_back(2);
to.push_back(3);
to.push_back(4);
to.push_back(5);
//Write v to screen
//From http://www.richelbilderbeek.nl/CppCoutContainer.htm
std::copy(v.begin(),v.end(),std::ostream_iterator<int>(std::cout," "));
std::cout << std::endl;
for (int i = 0; i!=10; ++i)
{
v = Replace_range(v,from,to);
//Write v to screen
//From http://www.richelbilderbeek.nl/CppCoutContainer.htm
std::copy(v.begin(),v.end(),
std::ostream_iterator<int>(std::cout," "));
std::cout << std::endl;
}
}
|