-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (34 loc) · 1.16 KB
/
main.cpp
File metadata and controls
44 lines (34 loc) · 1.16 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
#include "main.h"
#include "problems.h"
#include <iostream>
#include <vector>
#include <string>
#include <chrono>
int main(int argc, char** argv) {
if (argc == 1) {
std::cout << "Available problems:" << std::endl;
for (auto& problem : problems) {
std::cout << problem.name << std::endl;
}
return 0;
}
for (int i = 1; i < argc; i++) {
bool problem_found = false;
for (auto& problem : problems) {
if (problem.name == argv[i]) {
problem_found = true;
std::cout << "Running " << problem.name << "..." << std::endl;
auto start = std::chrono::high_resolution_clock::now();
problem.function();
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
std::cout << "Elapsed time: " << duration << " ms" << std::endl;
break;
}
}
if (!problem_found) {
std::cout << "Problem not found: " << argv[i] << std::endl;
}
}
return 0;
}