-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdictionary.cpp
69 lines (62 loc) · 1.6 KB
/
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
66
67
68
69
/***********************************************************
* @名称: dictionary10815 (AC)
* @作者: Shawn
* @创建时间: 2017-12-03 09:45:11
* @修改人: Shawn
* @修改时间: 2017-12-03 09:45:11
* @备注: set练习题
* @题目来源: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1756
***********************************************************/
#include <fstream>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main()
{
ifstream fin("dictionaryLOL.in");
ofstream fout("dictionary.out");
set<string> a;
int length = 0;
while (!fin.eof())
{
string temp;
fin >> temp;
if (temp == "")
{
break;
}
int lengthStr = temp.length();
string ans = "";
for (int i = 0; i <= lengthStr - 1; ++i)
{
char now = temp[i];
if (now >= 'a' && now <= 'z')
{
ans += now;
}
else if (now >= 'A' && now <= 'Z')
{
ans += now - 'A' + 'a';
}
else if (ans != "")
{
++length;
a.insert(ans);
//fout << "ans is " << ans << '\n';
ans = "";
}
}
if (ans != "")
{
++length;
a.insert(ans);
}
}
for (auto pos = a.begin(); pos != a.end(); ++pos)
{
fout << *(pos) << '\n';
}
return 0;
}