#include ‹iostream.h›
#include ‹stl.h›
int array[4] = {3, 1, 4, 2};
int main() {
sort(array, array + 4, less_equal‹int›());
for (int i = 0; i ‹ 4; i++) cout ‹‹ array[i] ‹‹ endl;
return 0;
}
divides.cpp
#include ‹iostream.h›
#include ‹stl.h›
int input[3] = {2, 3, 4};
int main() {
int result = accumulate(input, input + 3, 48, divides‹int›());
cout ‹‹ 'result = ' ‹‹ result ‹‹ endl;
return 0;
}
greater.cpp
#include ‹iostream.h›
#include ‹stl.h›
int array[4] = {3, 1, 4, 2};
int main() {
sort(array, array + 4, greater‹int›());
for (int i = 0; i ‹ 4; i++) cout ‹‹ array[i] ‹‹ endl;
return 0;
}
swap1.cpp
#include ‹stl.h›
#include ‹iostream.h›
int main() {
int a = 42;
int b = 19;
cout ‹‹ 'a = ' ‹‹ a ‹‹ ' b = ' ‹‹ b ‹‹ endl;
swap(a, b);
cout ‹‹ 'a = ' ‹‹ a ‹‹ ' b = ' ‹‹ b ‹‹ endl;
return 0;
}
times.cpp
#include ‹iostream.h›
#include ‹stl.h›
int input[4] = {1, 5, 7, 2};
int main() {
int total = accumulate(input, input + 4, 1, times‹int›());
cout ‹‹ 'total = ' ‹‹ total ‹‹ endl;
return 0;
}
less.cpp
#include ‹iostream.h›
#include ‹stl.h›
int array[4] = {3, 1, 4, 2};
int main() {
sort(array, array + 4, less‹int› ());
for (int i = 0; i ‹ 4; i++) cout ‹‹ array[i] ‹‹ endl;
return 0;
}
alg1.cpp
#include ‹iostream.h›
#include ‹stl.h›
int main() {
int i = min(4, 7);
cout ‹‹ 'min(4, 7) = ' ‹‹ i ‹‹ endl;
char c = maX('a', 'z');
cout ‹‹ 'maX('a', 'z') = ' ‹‹ c ‹‹ endl;