-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
49 lines (39 loc) · 1.36 KB
/
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
45
46
47
48
49
#include <iostream>
#include <fstream>
#include <string>
#include <random>
#include <chrono>
const std::string CHARSET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ";
std::string generate_line(size_t length, std::mt19937& gen, std::uniform_int_distribution<>& dis) {
std::string line;
for (size_t i = 0; i < length; ++i) {
line += CHARSET[dis(gen)];
}
return line;
}
int main() {
size_t LINE_LENGTH, LINES_PER_PAGE, PAGES_TO_GENERATE;
std::cout << "Enter the length of each line: ";
std::cin >> LINE_LENGTH;
std::cout << "Enter the number of lines per page: ";
std::cin >> LINES_PER_PAGE;
std::cout << "Enter the number of pages to generate: ";
std::cin >> PAGES_TO_GENERATE;
std::ofstream file("babylonian_library.txt");
if (!file.is_open()) {
std::cerr << "Unable to open file" << std::endl;
return 1;
}
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, CHARSET.size() - 1);
for (size_t page = 0; page < PAGES_TO_GENERATE; ++page) {
for (size_t line = 0; line < LINES_PER_PAGE; ++line) {
std::string line_text = generate_line(LINE_LENGTH, gen, dis);
file << line_text << std::endl;
}
file << "\n--- Page " << page + 1 << " ---\n" << std::endl;
}
file.close();
return 0;
}