-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (37 loc) · 892 Bytes
/
main.cpp
File metadata and controls
44 lines (37 loc) · 892 Bytes
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
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include "maxprofit.h"
#include "highestProductOf3.h"
using namespace std;
vector<int> generate_values() {
srand (time(NULL));
vector<int> values;
for (int i=0; i < 10; ++i) {
int num = rand() % 10 + 1;
values.push_back(num);
}
return values;
}
int main(int argc, const char * argv[]) {
vector<int> values = generate_values();
string method = string(argv[1]);
for (size_t i = 0; i < values.size(); ++i) {
cout << values[i] << " ";
}
cout << "\n";
if (method == "maxprofit") {
cout << maxProfit(values) << "\n";
}
else if (method == "highestProductOf3") {
cout << highestProductOf3(values) << "\n";
}
else {
for (int i = 1; i < argc; ++i) {
cout << argv[i] << " ";
}
cout << "\n";
}
return 0;
}