-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.cpp
45 lines (34 loc) · 937 Bytes
/
example.cpp
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
// example.cpp
#include <iostream>
#include <vector>
/**
* @function someFunc
* @desc Multiplies every number in the collection of given input numbers by
* the given multiplier
*
* @param {std::vector<int>} _v Collection of integers
* @param {int} _multiplier Amount to multiply every number by
* @returns {std::vector<int>} Collection of results
*/
auto times(const std::vector<int>& _v, const int& _multiplier){
std::vector<int> res;
for(auto &x: _v){
res.push_back(x * _multiplier);
}
return res;
}
int main(){
std::vector<int> my_vec{4, 6, 8, 2, 1};
auto twice = times(my_vec, 2);
std::cout << "Double of my_vec:";
for (auto &x: twice){
std::cout << ' ' << x;
}
std::cout << '\n';
auto thrice = times(my_vec, 3);
std::cout << "Thrice of my_vec:";
for (auto &x: thrice){
std::cout << ' ' << x;
}
return 0;
}