-
-
Notifications
You must be signed in to change notification settings - Fork 78
/
andys_first_dictionary.cpp
65 lines (51 loc) · 1.26 KB
/
andys_first_dictionary.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
63
64
65
// https://www.urionlinejudge.com.br/judge/en/problems/view/1215
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;
vector<string> parseString(string word) {
vector<string> v;
int len = 0, base = 0, ascChar;
for (int i = 0; i < word.size(); i++) {
ascChar = word[i];
if (ascChar < 65 || (ascChar > 90 && ascChar < 97) || ascChar > 122) {
v.push_back(word.substr(base, len));
base = i+1;
len = -1;
}
len++;
}
v.push_back(word.substr(base, len));
return v;
}
string lowerCase(string word) {
string lowerCaseWord = "";
char charac;
int ascChar;
for (int i = 0; i < word.size(); i++) {
ascChar = word[i];
if (ascChar >= 65 && ascChar <= 90) {
charac = ascChar + 32;
lowerCaseWord += charac;
} else {
lowerCaseWord += word[i];
}
}
return lowerCaseWord;
}
int main() {
string word, parsedWord;
set<string> s;
vector<string> v;
while (cin >> word) {
v = parseString(word);
for (int i = 0; i < v.size(); i++) {
parsedWord = lowerCase(v[i]);
if (parsedWord != "" && parsedWord != " ") s.insert(parsedWord);
}
}
for (set<string>::iterator it = s.begin(); it != s.end(); ++it)
cout << *it << endl;
return 0;
}