11003 - Palindrome   

Description

Palindrome is a string that is identical to its reverse, like "level" or "aba". Check whether a given string is a palindrome or not. 

Create a class SimpleString that manipulates a given string of characters. This class contains proper constructor functions (default constructor and copy constructor) and supports the following operations (in the form of member functions):

  • Ÿ   Overloading the assignment operator (=) to assign one given SimpleString object to the current SimpleString object.
  • Ÿ   Reversing the string which is stored in the SimpleString object.
  • Ÿ   Overloading the relational operator (==) to check whether two strings, which are stored in two SimpleString objects, are the same or not.

To check if a given string is a palindrome, we have provided another class PalindromeChecker as follows:

class PalindromeChecker

{

public:

    PalindromeChecker(const SimpleString &s)

    {

        str = s;

        rev = s;

        rev.reverse();

    };

    void isPalindrome()

    {

        if(rev == str)

            std::cout << "Yes\n";

        else

            std::cout << "No\n";

    };

private:

    SimpleString str;

    SimpleString rev;

};

Note:

This problem involves three files.

  •   function.h: Class definition of SimpleString.
  •   function.cpp: Member-function definitions of SimpleString.
  •   main.cpp: A driver program to test your class implementation.

You will be provided with main.cpp and function.h, and asked to implement function.cpp.

Note that you don’t need to implement class PalindromeChecker

function.h

main.cpp

Input

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. 

Output

For each test case, output "Yes" if it's a palindrome or "No" if it's not a palindrome in a line. 

Sample Input  Download

Sample Output  Download

Partial Judge Code

11003.cpp

Partial Judge Header

11003.h

Tags

10402HW7



Discuss