// Cに合わせて修正
#include <iostream>
#include <algorithm>
#include <cctype>
int is_palindrome( std:: string S ) {
S.erase ( std:: copy_if ( S.begin ( ) , S.end ( ) , S.begin ( ) , isalpha ) , S.end ( ) ) ;
std:: transform ( S.begin ( ) , S.end ( ) , S.begin ( ) , :: toupper ) ;
return std:: equal ( S.begin ( ) , S.end ( ) , S.rbegin ( ) ) ;
}
// -----------------------------------------------------------------------------
// http://t...content-available-to-author-only...h.net/test/read.cgi/tech/1357191974/277
//
void check_palindrome( const char * cs) {
printf ( "\" %s\" %s a palindrome.\n " , cs, is_palindrome( cs) ? "is" : "is NOT" ) ;
}
int main( ) {
check_palindrome( "boo" ) ;
check_palindrome( "A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal-Panama!" ) ;
check_palindrome( "A tin mug for a jar of gum, Nita." ) ;
check_palindrome( "A Toyota! Race fast, safe car! A Toyota!" ) ;
return 0 ;
}
Ly8gQ+OBq+WQiOOCj+OBm+OBpuS/ruatowojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxjY3R5cGU+CgppbnQgaXNfcGFsaW5kcm9tZSggc3RkOjpzdHJpbmcgUyApIHsKCVMuZXJhc2UoIHN0ZDo6Y29weV9pZiAgKCBTLmJlZ2luKCksIFMuZW5kKCksIFMuYmVnaW4oKSwgICBpc2FscGhhICksIFMuZW5kKCkgKTsKCSAgICAgICAgIHN0ZDo6dHJhbnNmb3JtKCBTLmJlZ2luKCksIFMuZW5kKCksIFMuYmVnaW4oKSwgOjp0b3VwcGVyICk7CglyZXR1cm4gICBzdGQ6OmVxdWFsICAgICggUy5iZWdpbigpLCBTLmVuZCgpLCBTLnJiZWdpbigpICk7Cn0KCi8vIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCi8vIGh0dHA6Ly90Li4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5oLm5ldC90ZXN0L3JlYWQuY2dpL3RlY2gvMTM1NzE5MTk3NC8yNzcKLy8Kdm9pZCBjaGVja19wYWxpbmRyb21lKGNvbnN0IGNoYXIgKmNzKSB7IApwcmludGYoIlwiJXNcIiAlcyBhIHBhbGluZHJvbWUuXG4iLCBjcywgaXNfcGFsaW5kcm9tZShjcykgPyAiaXMiIDogImlzIE5PVCIpOyAKfSAKaW50IG1haW4oKSB7IApjaGVja19wYWxpbmRyb21lKCJib28iKTsgCmNoZWNrX3BhbGluZHJvbWUoIkEgbWFuLCBhIHBsYW4sIGEgY2F0LCBhIGhhbSwgYSB5YWssIGEgeWFtLCBhIGhhdCwgYSBjYW5hbC1QYW5hbWEhIik7IApjaGVja19wYWxpbmRyb21lKCJBIHRpbiBtdWcgZm9yIGEgamFyIG9mIGd1bSwgTml0YS4iKTsgCmNoZWNrX3BhbGluZHJvbWUoIkEgVG95b3RhISBSYWNlIGZhc3QsIHNhZmUgY2FyISBBIFRveW90YSEiKTsgCnJldHVybiAwOyAKfSAK
stdout
"boo" is NOT a palindrome.
"A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal-Panama!" is a palindrome.
"A tin mug for a jar of gum, Nita." is a palindrome.
"A Toyota! Race fast, safe car! A Toyota!" is a palindrome.