(TOJ3260)Palindromes

描述

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.

输入

Each line of input contains one word with no embedded spaces. Each word will have only alphabetic characters (either upper or lower case).

输出

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.

样例输入

eyE
laLAlal
Foof
foobar

样例输出

yes
yes
yes
no

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<ctype.h>
 4 #include<math.h>
 5 
 6 char s[65536];
 7 
 8 void solve()
 9 {
10     int i,len;
11     while(gets(s))
12     {
13      len=strlen(s);
14       for(i=0; i<len/2; i++)
15       {
16           if(tolower(s[i])!=tolower(s[len-1-i]))
17             break;
18        }
19       if(i==len/2)
20         printf("yes\n");
21     else
22       printf("no\n");
23     }
24 }
25 
26 int main()
27 {
28   solve(s);
29   getchar();
30   getchar();
31     return 0;
32 }

 

转载于:https://www.cnblogs.com/xueda120/archive/2013/05/10/3071010.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值