2013-04-10 23:57:08 -07:00
|
|
|
#include <algorithm>
|
|
|
|
|
#include <cctype>
|
|
|
|
|
#include <string>
|
2016-12-05 22:15:40 +01:00
|
|
|
#include <iostream>
|
2013-04-10 23:57:08 -07:00
|
|
|
|
2016-12-05 22:15:40 +01:00
|
|
|
const std::string alphabet("abcdefghijklmnopqrstuvwxyz");
|
2013-04-10 23:57:08 -07:00
|
|
|
|
2016-12-05 22:15:40 +01:00
|
|
|
bool is_pangram(std::string s)
|
|
|
|
|
{
|
|
|
|
|
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
|
|
|
|
|
std::sort(s.begin(), s.end());
|
|
|
|
|
return std::includes(s.begin(), s.end(), alphabet.begin(), alphabet.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
const auto examples = {"The quick brown fox jumps over the lazy dog",
|
|
|
|
|
"The quick white cat jumps over the lazy dog"};
|
|
|
|
|
|
|
|
|
|
std::cout.setf(std::ios::boolalpha);
|
|
|
|
|
for (auto& text : examples) {
|
|
|
|
|
std::cout << "Is \"" << text << "\" a pangram? - " << is_pangram(text) << std::endl;
|
|
|
|
|
}
|
2013-04-10 23:57:08 -07:00
|
|
|
}
|