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