-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
62 lines (44 loc) · 1.11 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
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <fstream>
#include "List.h"
#include "Word.h"
using namespace std;
const char input[] = "input.txt";
const char output[] = "output.txt";
int main() {
string text;
ifstream inputFile(input, ios::in);
List<Word> vowels;
List<Word> consonants;
if (inputFile.is_open()) {
string text;
while (inputFile >> text) {
Word word(text);
if (word.getSize() != 0) {
if (word.isLastLetterVowel()) {
vowels.push(word);
} else {
consonants.push(word);
}
}
}
inputFile.close();
}
vowels.sort();
consonants.sort();
ofstream outputFile(output);
if (outputFile.is_open()) {
outputFile << "Согласные: " << endl << endl;
for (int i = 0; i < consonants.getSize(); i++) {
Word elem = consonants.getElement(i);
outputFile << elem.getValue() << ' ' << elem.lettersRatio() << endl;
}
outputFile << endl;
outputFile << "Гласные: " << endl << endl;
for (int i = 0; i < vowels.getSize(); i++) {
Word elem = vowels.getElement(i);
outputFile << elem.getValue() << ' ' << elem.lettersRatio() << endl;
}
outputFile.close();
}
}