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_or‹bool›());
for (int i = 0; i ‹ 4; i++) cout ‹‹ output[i] ‹‹ endl;
return 0;
}
nequal.cpp
#include ‹iostream.h›
#include ‹stl.h›
int input1[4] = {1, 7, 2, 2};
int input2[4] = {1, 6, 2, 3};
int main() {
int output[4];
transform(input1, input1 + 4, input2, output, not_equal_to‹int›());
for (int i = 0; i ‹ 4; i++) cout ‹‹ output[i] ‹‹ endl;
return 0;
}
ptition0.cpp
#include ‹stl.h›
#include ‹iostream.h›
int less_10(int a_) {
return a_ ‹ 10 ? 1 : 0;
}
int numbers[6] = {6, 12, 3, 10, 1, 20};
int main() {
partition(numbers, numbers + 6, less_10);
for (int i = 0; i ‹ 6; i++) cout ‹‹ numbers[i] ‹‹ ' ';
cout ‹‹ endl;
return 0;
}
inrprod0.cpp
#include ‹stl.h›
#include ‹iostream.h›
#include ‹string.h›
int vector1[5] = {1, 2, 3, 4, 5};
int vector2[5] = {1, 2, 3, 4, 5};
int main() {
int result;
result = inner_product(vector1, vector1 + 5, vector2, 0);
cout ‹‹ 'Inner product = ' ‹‹ result ‹‹ endl;
return 0;
}
func3.cpp
#include ‹iostream.h›
#include ‹stl.h›
int main() {
vector‹int›v;
v.push_back(4);
v.push_back(1);
v.push_back(5);
sort(v.begin(), v.end(), greater‹int›());
vector‹int›::iterator i;
for (i = v.begin(); i != v.end(); i++) cout ‹‹ *i ‹‹ endl;
return 0;
}
modulus.cpp
#include ‹iostream.h›
#include ‹stl.h›
int input1[4] = {6, 8, 10, 2};
int input2[4] = {4, 2, 11, 3};
int main() {
int output[4];
transform(input1, input1 + 4, input2, output, modulus‹int›());
for (int i = 0; i ‹ 4; i++) cout ‹‹ output[i] ‹‹ endl;
return 0;
}