-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathgenerate-data.cpp
More file actions
31 lines (25 loc) · 874 Bytes
/
generate-data.cpp
File metadata and controls
31 lines (25 loc) · 874 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
#include <fstream>
#include <random>
#include <iostream>
int main() {
std::random_device rd;
std::mt19937 gen(rd());
std::default_random_engine generator(std::random_device{}());
std::uniform_int_distribution<int> amountDistribution(101, 999);
std::discrete_distribution<int> customerDistribution({40, 20, 10, 10, 5, 5, 5, 3, 2});
int number_of_sales = 10 * 1000;
std::ofstream outputFile("output.txt");
if (outputFile.is_open()) {
for (int i = 0; i < number_of_sales; ++i) {
// +1 to get IDs from 1 to 10
int customerId = customerDistribution(gen);
int amount = amountDistribution(gen);
outputFile << customerId << " " << amount << "\n";
}
outputFile.close();
} else {
std::cerr << "Unable to open file";
}
outputFile.close();
return 0;
}