-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
87 lines (85 loc) · 1.72 KB
/
Copy pathmain.cpp
File metadata and controls
87 lines (85 loc) · 1.72 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
#include <algorithm>
#include <ctime>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "BinaryTree.hpp"
int main()
{
std::ifstream dictionaryInput;
dictionaryInput.open("Dictionary.txt");
std::vector<std::string> dictionary;
while (dictionaryInput)
{
std::string temp;
dictionaryInput >> temp;
dictionary.push_back(temp);
}
std::random_shuffle(dictionary.begin(), dictionary.end());
for (unsigned int i = 0; i < dictionary.size(); i++)
{
for (unsigned int j = 0; j < dictionary[i].length(); j++)
{
if (dictionary[i][j] == '\'')
{
dictionary[i][j] = dictionary[i][j + 1];
dictionary[i][j + 1] = 0;
}
}
}
BinaryTree<std::string> tree;
std::cout << dictionary.size();
for (unsigned int i = 0; i < dictionary.size(); i++)
{
tree.insert(dictionary[i]);
}
tree.statInfo();
std::ifstream letterInput;
letterInput.open("Letter.txt");
std::vector<std::string> letter;
while (letterInput)
{
std::string temp;
letterInput >> temp;
letter.push_back(temp);
}
for (unsigned int i = 0; i < letter.size(); i++)
{
for (unsigned int j = 0; j < letter[i].length(); j++)
{
switch (letter[i][j])
{
case'"':
case',':
case':':
case'.':
case'!':
case'?':
case'(':
case')':
letter[i].erase(j);
break;
}
if (isupper(letter[i][j]))
{
letter[i][j] = tolower(letter[i][j]);
}
}
}
std::cout << std::endl
<< std::endl
<< "list of misspelled words"
<< std::endl
<< std::endl;
for (unsigned int i = 0; i < letter.size(); i++)
{
if (!tree.search(letter[i]))
{
std::cout
<< letter[i]
<< std::endl;
}
}
return 0;
}