Skip to content

Instantly share code, notes, and snippets.

@WindAzure
Created November 5, 2019 16:13
Show Gist options
  • Save WindAzure/9a76cfa13812a37735127c9b765a220f to your computer and use it in GitHub Desktop.
Save WindAzure/9a76cfa13812a37735127c9b765a220f to your computer and use it in GitHub Desktop.
UVa 10815
#include <algorithm>
#include <iostream>
#include <iterator>
#include <regex>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
int main()
{
auto dictionary = set<string> {};
auto pattern = regex("[a-zA-Z]+");
string lineInArticle;
while (getline(cin, lineInArticle))
{
transform(lineInArticle.begin(), lineInArticle.end(), lineInArticle.begin(), [](const char character) { return tolower(character); });
copy(sregex_token_iterator(lineInArticle.begin(), lineInArticle.end(), pattern), sregex_token_iterator(),
inserter(dictionary, dictionary.begin()));
}
for (const auto &words: dictionary)
{
cout << words << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment