-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ_Andys-First-Dictionary.cpp
More file actions
39 lines (37 loc) · 944 Bytes
/
Q_Andys-First-Dictionary.cpp
File metadata and controls
39 lines (37 loc) · 944 Bytes
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
#include <iostream>
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main()
{
string word;
map<string, int> dictionary;
vector<string> item;
while (cin >> word)
{
// if (word.compare("#") == 0)
// break;
for (int i = 0; i != word.size();)
{
if (isalpha(word[i]))
{
int j = i;
while (j != word.size() && isalpha(word[j]))
{
word[j] = tolower(word[j]);
j++;
}
string temp = word.substr(i, j - i);
if (temp != "")
{
dictionary[temp]++;
}
i = j;
}
else
i++;
}
}
for (map<string, int>::iterator itr = dictionary.begin(); itr != dictionary.end(); itr++)
cout << itr->first << endl;
}