10840 - Check 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.
 

Note that

1.      This problem involves three files.

  • function.h: Function definition of isPalindrome.
  • function.c: Function describe of isPalindrome.
  • main.c: A driver program to test your implementation.

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

2.     For OJ submission:

       Step 1. Submit only your function.c into the submission block. (Please choose c compiler) 

       Step 2. Check the results and debug your program if necessary.

function.h

#ifndef FUNCTION_H
#define FUNCTION_H
int isPalindrome(char *start, char *end);
#endif

main.c

#include <stdio.h>
#include <string.h>
#include "function.h"

int main()
{
        char str[5000];
        while (EOF != scanf("%s", str))
        {
                char *start = str;
                char *end = start + strlen(str) - 1;
                if (isPalindrome(start, end))
                {
                        printf("Yes\n");
                }
                else
                {
                        printf("No\n");
                }
        }
}

Input

The input consists of multiple lines. Each line contains a string.
The length of each string is less than 5000.  The number of test case is less than 100.

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

10840.c

Partial Judge Header

10840.h

Tags

10401HW9



Discuss