ptrunf2.cpp
#include ‹iostream.h›
#include ‹stl.h›
bool even(int n_) {
return (n_ % 2) == 0;
}
int array[3] = {1, 2, 3};
int main() {
int* p = find_if(array, array + 3, ptr_fun(even));
if (p != array + 3) cout ‹‹ *p ‹‹ ' is even' ‹‹ endl;
return 0;
}
rotcopy0.cpp
#include ‹stl.h›
#include ‹iostream.h›
int numbers[6] = {0, 1, 2, 3, 4, 5};
int main() {
int result[6];
rotate_copy(numbers, numbers + 3, numbers + 6, result);
for (int i = 0; i ‹ 6; i++) cout ‹‹ result[i] ‹‹ ' ';
cout ‹‹ endl;
return 0;
}
mkheap0.cpp
#include ‹stl.h›
#include ‹iostream.h›
int numbers[6] = {5, 10, 4, 13, 11, 19};
int main() {
make_heap(numbers, numbers + 6);
for (int i = 6; i ›= 1; i--) {
cout ‹‹ numbers[0] ‹‹ endl;
pop_heap(numbers, numbers + i);
}
return 0;
}
copy1.cpp
#include ‹stl.h›
#include ‹iostream.h›
#include ‹string.h›
char string[23] = 'A string to be copied.';
int main() {
char result[23];
copy(string, string + 23, result);
cout ‹‹ ' Src: ' ‹‹ string ‹‹ '
Dest: ' ‹‹ result ‹‹ endl;
return 0;
}
find0.cpp
#include ‹stl.h›
#include ‹iostream.h›
int numbers[10] = {0, 1, 4, 9, 16, 25, 36, 49, 64};
int main() {
int* location;
location = find(numbers, numbers + 10, 25);
cout ‹‹ 'Found 25 at offset ' ‹‹ (location - numbers) ‹‹ endl;
return 0;
}
partsum0.cpp
#include ‹stl.h›
#include ‹iostream.h›
int numbers[6] = {1, 2, 3, 4, 5, 6};
int main() {
int result[6];
partial_sum(numbers, numbers + 6, result);
for (int i = 0; i ‹ 6; i ++) cout ‹‹ result[i] ‹‹ ' ';
cout ‹‹ endl;