-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
44 lines (33 loc) · 1008 Bytes
/
main.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
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
int getSum(vector<int> vectorToBeSummed){
int resultOfSum = 0;
for(auto iterator:vectorToBeSummed ){
resultOfSum += iterator;
}
return resultOfSum;
}
int getMin(vector<int> vectorToGetMinOf){
int minimum = 1000000;
for(auto iterator:vectorToGetMinOf){
minimum = min(minimum,iterator);
}
return minimum;
}
int getAverage(vector<int> vectorToBeAveraged){
int resultOfSum = getSum(vectorToBeAveraged);
int numberOfElementsInVector = vectorToBeAveraged.size();
int resultOfAverage = resultOfSum/numberOfElementsInVector;
return resultOfAverage;
}
int main(){
vector<int> sumVector = {1,2,3,4,5,6,7,8,9,10};
cout << getSum(sumVector) << "\n";
vector<int> averageVector = {1,2,3,4,5,6,7,8,9,10};
cout << getAverage(averageVector) << "\n";
vector<int> minVetor = {1,2,3,4,5,6,7,8,9,10};
cout << getMin(minVetor) << "\n";
return 0;
}