stblptn0.cpp
#include ‹stl.h›
#include ‹iostream.h›
bool less_10(int a_) {
return a_ ‹ 10 ? 1 : 0;
}
int numbers[6] = {10, 5, 11, 20, 6, -2};
int main() {
stable_partition(numbers, numbers + 6, less_10);
for (int i = 0; i ‹ 6; i++) cout ‹‹ numbers[i] ‹‹ ' ';
cout ‹‹ endl;
return 0;
}
setunon0.cpp
#include ‹stl.h›
#include ‹iostream.h›
int v1[3] = {13, 18, 23};
int v2[4] = {10, 13, 17, 23};
int result[7] = {0, 0, 0, 0, 0, 0, 0};
int main() {
set_union(v1, v1 + 3, v2, v2 + 4, result);
for (int i = 0; i ‹ 7; i++) cout ‹‹ result[i] ‹‹ ' ';
cout ‹‹ endl;
return 0;
}
mkheap1.cpp
#include ‹stl.h›
#include ‹iostream.h›
int numbers[6] = {5, 10, 4, 13, 11, 19};
int main() {
make_heap(numbers, numbers + 6, greater‹int›());
for (int i = 6; i ›= 1; i--) {
cout ‹‹ numbers[0] ‹‹ endl;
pop_heap(numbers, numbers + i, greater‹int›());
}
return 0;
}
setintr0.cpp
#include ‹stl.h›
#include ‹iostream.h›
int v1[3] = {13, 18, 23};
int v2[4] = {10, 13, 17, 23};
int result[4] = {0, 0, 0, 0};
int main() {
set_intersection(v1, v1 + 3, v2, v2 + 4, result);
for (int i = 0; i ‹ 4; i++) cout ‹‹ result[i] ‹‹ ' ';
cout ‹‹ endl;
return 0;
}
logicand.cpp
#include ‹iostream.h›
#include ‹stl.h›
bool input1[4] = {1, 1, 0, 1};
bool input2[4] = {0, 1, 0, 0};
int main() {
int output[4];
transform(input1, input1 + 4, input2, output, logical_and‹bool›());
for (int i = 0; i ‹ 4; i++) cout ‹‹ output[i] ‹‹ endl;
return 0;
}
logicor.cpp
#include ‹iostream.h›
#include ‹stl.h›