Palindrome is a string that is identical to its reverse, like "level" or "aba". Check whether a given string is a palindrome or not.
// function.h
#include <iostream>
#include <string>
using namespace std;
class PalindromeChecker
{
private:
static const int MAXWORDLENTH=100001;
char word[MAXWORDLENTH];//store the input string
public:
PalindromeChecker();
PalindromeChecker(const char*);
PalindromeChecker& operator=(const PalindromeChecker& p);
void reverse();
friend bool operator== (PalindromeChecker &p1, PalindromeChecker &p2);
};
main.cpp
// main.cpp
#include <iostream>
#include "function.h"
using namespace std;
int main()
{
char word[100001];
while(cin >> word){
PalindromeChecker p1(word);
PalindromeChecker p2;
p2 = p1;
p2.reverse();
if(p1==p2)
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
The input consists of multiple lines. Each line contains a string. The length of each string is less than 100000. The number of test case is less than 1000.
For each test case, output "Yes" if it's a palindrome or "No" if it's not a palindrome in a line.