0063 - Palindrome
#include <iostream> #include <string> using namespace std; bool Slove(string word) { int i; for (i=0; i<word.length()/2; ++i) if ( word[i] != word[ (word.length()-1)-i ] ) break; return (i == word.length()/2)? true : false; } int main(void) { int count=0; string word; while (cin >> word) count+=Slove(word); cout << count << endl; return 0; }
やるだけ