zoukankan      html  css  js  c++  java
  • (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 }
    
    
     
  • 相关阅读:
    一个APP爆炸的时代,假设没有wifi
    POJ2393 Yogurt factory 【贪心】
    Levenberg–Marquardt algorithm
    keepalived+nginx安装配置
    測试赛D
    脚本中$
    vm+ubuntu联网
    操作系统从硬件到应用程序之间的关系
    【转】linux驱动开发
    Qt如何重写虚函数
  • 原文地址:https://www.cnblogs.com/xueda120/p/3071010.html
Copyright © 2011-2022 走看看