Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <cctype>
- #include <iostream>
- #include <string>
- int main(int argc, char ** argv) {
- std::for_each(argv + 1, argv + argc, [](char * text) {
- std::string input{text};
- auto const b = std::begin(input);
- auto const it = std::stable_partition(b, std::end(input),
- [](auto v) {
- return std::isalpha(v);
- });
- std::transform(b, it, b, [](auto v) {
- return std::tolower(v);
- });
- auto const middle = std::next(b, std::distance(b, it)/2);
- std::cout << text << " => ";
- if(!std::equal(b, middle, std::make_reverse_iterator(it))) {
- std::cout << "not ";
- }
- std::cout << " palindrome\n";
- });
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement