-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.cpp
More file actions
30 lines (26 loc) · 785 Bytes
/
generate.cpp
File metadata and controls
30 lines (26 loc) · 785 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
#include <iostream>
#include <fstream>
#include <ctime>
#include <cmath>
#include <chrono>
void generate_input_files(int n) {
srand(time(NULL));
std::ofstream outfile("../inputs/" + std::to_string(n) + ".in");
for (int i = 0; i < n; ++i) {
outfile << rand() % n << "\n";
}
outfile.close();
}
void generate_files() {
for (int i = 10; i <= pow(10, 7); i *= 10) {
generate_input_files(i);
}
}
int main() {
auto start = std::chrono::high_resolution_clock::now();
generate_files();
auto end = std::chrono::high_resolution_clock::now();
double duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
std::cout << "Ejecucion exitosa en " << duration * 1e-9 << " s" << std::endl;
return 0;
}