min2.cpp
#include ‹stl.h›
#include ‹iostream.h›
#include ‹string.h›
bool str_compare(const char* a_, const char* b_) {
return ::strcmp(a_, b_) ‹ 0 ? 1 : 0;
}
int main() {
cout ‹‹ min('shoe', 'shine', str_compare) ‹‹ endl;
return 0;
}
parsrt0.cpp
#include ‹stl.h›
#include ‹iostream.h›
int numbers[6] = {5, 2, 4, 3, 1, 6};
int main() {
partial_sort(numbers, numbers + 3, numbers + 6);
for (int i = 0; i ‹ 6; i++) cout ‹‹ numbers[i] ‹‹ ' ';
cout ‹‹ endl;
return 0;
}
partsrt0.cpp
#include ‹stl.h›
#include ‹iostream.h›
int numbers[6] = {5, 2, 4, 3, 1, 6};
int main() {
partial_sort(numbers, numbers + 3, numbers + 6);
for (int i = 0; i ‹ 6; i++) cout ‹‹ numbers[i] ‹‹ ' ';
cout ‹‹ endl;
return 0;
}
bnegate1.cpp
#include ‹iostream.h›
#include ‹stl.h›
int array[4] = {4, 9, 7, 1};
int main() {
sort(array, array + 4, binary_negate‹greater‹int› ›(greater‹int›()));
for (int i = 0; i ‹ 4; i++) cout ‹‹ array[i] ‹‹ endl;
return 0;
}
nthelem0.cpp
#include ‹stl.h›
#include ‹iostream.h›
int numbers[6] = {5, 2, 4, 1, 0, 3};
int main() {
nth_element(numbers, numbers + 3, numbers + 6);
for (int i = 0; i ‹ 6; i++) cout ‹‹ numbers[i] ‹‹ ' ';
cout ‹‹ endl;
return 0;
}
revbit2.cpp
#include ‹iostream.h›
#include ‹stl.h›
int array[] = {1, 5, 2, 3};
int main() {
list‹int› v(array, array + 4);
list‹int›::reverse_iterator r;
for (r = v.rbegin(); r != v.rend(); r++) cout ‹‹ *r ‹‹ endl;
return 0;
}