-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunadap.cpp
More file actions
45 lines (36 loc) · 1.1 KB
/
Copy pathfunadap.cpp
File metadata and controls
45 lines (36 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// Created by 赵健 on 2021/8/17.
//
#include "funadap.h"
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <functional>
#include "../../utils/Utils.h"
const int LIM = 6;
void funadap::test() {
using namespace std;
double arr1[LIM] = {28, 29, 30, 35, 38, 59};
double arr2[LIM] = {63, 65, 69, 75, 80, 99};
vector<double> gr8(arr1, arr1 + LIM);
vector<double> m8(arr2, arr2 + LIM);
cout.setf(ios_base::fixed);
cout.precision(1);
cout << "gr8:\t";
for_each(gr8.begin(), gr8.end(), Utils::ShowDouble);
cout << endl;
cout << "m8 :\t";
for_each(m8.begin(), m8.end(), Utils::ShowDouble);
cout << endl;
vector<double> sum(LIM);
transform(gr8.begin(), gr8.end(), m8.begin(), sum.begin(), plus<double>());
cout << "sum:\t";
for_each(sum.begin(), sum.end(), Utils::ShowDouble);
cout << endl;
vector<double> prod(LIM);
transform(gr8.begin(), gr8.end(), prod.begin(), bind1st(multiplies<double>(), 2.5));
cout << "prod:\t";
for_each(prod.begin(), prod.end(), Utils::ShowDouble);
cout << endl;
}