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 }
    
    
     
  • 相关阅读:
    (转)IDEA ERROR:找不到或无法加载主类
    Piggy-Bank
    Monkey and Banana
    Max Sum Plus Plus
    Doing Homework
    繁繁的游戏
    看试卷
    繁繁的队列
    大整数乘法
    文件操作(c++)
  • 原文地址:https://www.cnblogs.com/xueda120/p/3071010.html
Copyright © 2011-2022 走看看