Palindromes |
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB |
Total submit users: 184, Accepted users: 175 |
Problem 10136 : No special judgement |
Problem description |
Background: Palindromes are strings that read the same both forwards and backwards. `Eye' is one such example (ignoring case). In this problem, you get to write a program to determine if a given word is a palindrome or not. |
Input |
Each line of input contains one word with no embedded spaces. Each word will have only alphabetic characters (either upper or lower case). |
Output |
For each line of input, output either `yes' if the word is a palindrome or `no' otherwise. Don't print the quotes. Case should be ignored when checking the words. |
Sample Input |
eyE laLAlal Foof foobar |
Sample Output |
yes yes yes no |
Problem Source |
UD Contest |
#include <stdio.h>
#define YES 1
#define NO 0
main()
{
int flag;
char s[1000];
int i,j,n;
while( scanf("%s",s) > 0 ){
n = 0;
while( s[n] != '/0' ) n++;
for( i = 0 ; (i+1) <= (n/2) ; i++ ){
if( tolower(s[i])!= tolower(s[n-1-i]) ){flag=NO;break;}
else flag=YES;
}
if(flag==NO)printf("no/n");
else printf("yes/n");
}
return 0;
}
#define YES 1
#define NO 0
main()
{
int flag;
char s[1000];
int i,j,n;
while( scanf("%s",s) > 0 ){
n = 0;
while( s[n] != '/0' ) n++;
for( i = 0 ; (i+1) <= (n/2) ; i++ ){
if( tolower(s[i])!= tolower(s[n-1-i]) ){flag=NO;break;}
else flag=YES;
}
if(flag==NO)printf("no/n");
else printf("yes/n");
}
return 0;
}