-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbabelbot.cpp
More file actions
118 lines (109 loc) · 2.57 KB
/
Copy pathbabelbot.cpp
File metadata and controls
118 lines (109 loc) · 2.57 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/** //\
* V \
* \ \_
* \,'.`-.
* |\ `. `.
* ( \ `. `-. _,.-:\
* \ \ `. `-._ __..--' ,-';/
* \ `. `-. `-..___..---' _.--' ,'/
* `. `. `-._ __..--' ,' /
* `. `-_ ``--..'' _.-' ,'
* `-_ `-.___ __,--' ,'
* `-.__ `----""" __.-'
* `--..____..--'
*/
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
#include <time.h>
const int ascii_start = 97;
const int ascii_end = 122;
const int pageLength = 3200;
const int bookLength = 410;
const int lineBreak = 80;
/**
int msleep(unsigned long milisec)
{
struct timespec req={0};
time_t sec=(int)(milisec/1000);
milisec=milisec-(sec*1000);
req.tv_sec=sec;
req.tv_nsec=milisec*1000000L;
while(nanosleep(&req,&req)==-1)
continue;
return 1;
}
**/
void createPage(int page) {
int count = 0, spaces = 0, periods = 0, commas = 0;
std::ofstream nfile("Page" + std::to_string(page) + ".txt");
for (int i = 0; i < pageLength; i++) {
count++;
spaces++;
periods++;
commas++;
nfile << (char)(rand()
% ((ascii_end - ascii_start) + 1) + ascii_start);
if (spaces >= (rand() % 5) + rand() % 12) {
if (commas >= 15 + rand() % 50) {
if (rand()%2 == 0) {
nfile << ",";
commas = 0;
periods = 0;
count++;
} else {
commas = 0;
}
}
if (periods >= 15 + rand() % 50) {
if (rand()%4 != 0) {
nfile << ".";
periods = 0;
commas = 0;
count++;
} else {
periods = 0;
}
}
nfile << " ";
spaces = 0;
count++;
}
if (count >= lineBreak) {
nfile << "\n";
count = 0;
}
}
}
void createBook() {
int pageCount = 0;
for (int i = 0; i < bookLength; i++) {
pageCount++;
createPage(pageCount);
}
}
void electriceito() {
std::cout << "\nDon't waste electriceito\n";
std::cin.clear();
std::cin.ignore(1000, '\n');
}
int main(int argc, char *argv[]) {
srand(time(NULL));
if (argc == 1) {
electriceito();
} else {
std::string input = argv[1];
if (input == "book") {
createBook();
}
if (input == "page") {
int pageNum = atoi(argv[2]);
createPage(pageNum);
}
if (input != "book" and input != "page") {
electriceito();
}
}
return 0;
}