int main
#include <stl.h> #include <iostream.h>
int numbers[6] = { 0, 1, 2, 0, 1, 2 };
int main () { replace (numbers, numbers + 6, 2, 42); for (int i = 0; i < 6; i++) cout << numbers[i] << ' '; cout << endl; return 0; }
#include <stl.h> #include <iostream.h>
int main () { vector <int> v1 (10); for (int i = 0; i < v1.size (); i++) v1[i] = i % 5; ostream_iterator <int> iter (cout, " "); copy (v1.begin (), v1.end (), iter); cout << endl; replace (v1.begin (), v1.end (), 2, 42); copy (v1.begin (), v1.end (), iter); cout << endl; return 0; }