-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain(old).cpp
More file actions
105 lines (85 loc) · 3.04 KB
/
Copy pathmain(old).cpp
File metadata and controls
105 lines (85 loc) · 3.04 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
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <fstream>
using namespace std;
vector<char> vowels = {'a', 'e', 'i', 'o', 'y'};
vector<char> consonants = {'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm',
'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'z'};
vector<char> generateAlphabet() {
vector<char> alphabet;
int size = rand() % 11 + 6;
for (int i = 0; i < 2; i++) {
alphabet.push_back(vowels[rand() % vowels.size()]);
}
while (alphabet.size() < size) {
char letter;
if (rand() % 2 == 0) {
letter = vowels[rand() % vowels.size()];
} else {
letter = consonants[rand() % consonants.size()];
}
if (find(alphabet.begin(), alphabet.end(), letter) == alphabet.end()) {
alphabet.push_back(letter);
}
}
return alphabet;
}
string getLetterName(char letter) {
vector<string> endings = {"a", "e", "i", "o", "u"};
string name = "";
name += letter;
name += endings[rand() % endings.size()];
return name;
}
string generateWord(const vector<char>& alphabet) {
int length = rand() % 5 + 2;
string word = "";
for (int i = 0; i < length; i++) {
word += alphabet[rand() % alphabet.size()];
}
return word;
}
void exportLanguage(const vector<char>& alphabet, const vector<string>& words, const string& filename) {
ofstream file(filename);
if (!file.is_open()) {
cout << "Îøèáêà: íå óäàëîñü ñîçäàòü ôàéë!" << endl;
return;
}
file << "=== Project Babylone — ßçûê ===\n";
file << "\nÀëôàâèò (" << alphabet.size() << " áóêâ):\n";
for (char c : alphabet) {
file << " " << c << " (" << getLetterName(c) << ")\n";
}
file << "\nÏðèìåðû ñëîâ:\n";
for (const string& w : words) {
file << " " << w << "\n";
}
file.close();
cout << "ßçûê ñîõðàí¸í â ôàéë: " << filename << endl;
}
int main() {
srand(time(0));
system("chcp 1251>nul");
cout << "Äîáðî ïîæàëîâàòü â ProjectBabylone!" << endl;
cout << "Ýòî ïðîñòîé ãåíåðàòîð êîíëàíãîâ (èñê. ÿçûêîâ),\nêîòîðûé íàõîäèòñÿ â ñòàäèè ðàçðàáîòêè" << endl;
vector<char> alphabet = generateAlphabet();
vector<string> words;
for (int i = 0; i < 10; i++) {
words.push_back(generateWord(alphabet));
}
cout << "\nÀëôàâèò (" << alphabet.size() << " áóêâ):" << endl;
for (char c : alphabet) {
cout << " " << c << " (" << getLetterName(c) << ")" << endl;
}
cout << "\nÏðèìåðû ñëîâ:" << endl;
for (const string& w : words) {
cout << " " << w << endl;
}
string filename = "language_" + to_string(time(0)) + ".txt";
exportLanguage(alphabet, words, filename);
system("pause>nul");
return 0;
}