Judging palindrome (0315) Swust-oj

Source: Internet
Author: User

Description

A string that turns all its characters upside down and then calls it a palindrome. If 121 is a palindrome, ABA is not a palindrome. Your task is to determine whether a palindrome is an input string.

Input

First line: Number of test data groups N (1= next n rows:

One string per line (only numbers and letters (case sensitive), and the string size is less than 100).

Output

The output is only one row, that is, a palindrome. is the output "yes", not the output "no";

Sample Input3a1bb1a5454215644484412 Sample Outputyesnono I thought: because palindrome number is just read and backwards read all the same, that only need to compare the input character and the inverted character is the same; Code:


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ()
{
int n,i,len,j;

Char str[1000],stu[1000];

scanf ("%d", &n);

while (n--)
{
scanf ("%s", str);
Len=strlen (str);
for (i=len-1,j=0;i>=0;i--)//Put the input string upside down
{
Stu[j]=str[i];
j + +;
}
stu[len]=0; The value of the last character of the string ' \ s ' is 0;
if (strcmp (STU,STR)!=0)
{
printf ("NO");
}
Else
printf ("YES");
printf ("\ n");
}

return 0;
}

Judging palindrome (0315) Swust-oj

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.