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 }
    
    
     
  • 相关阅读:
    记一次小程序支付开发的坑,超级坑
    springboot集成redis 附redis基本操作类
    springboot整合mybatis及封装curd操作-配置文件
    微信小程序开发
    vue各种插件
    java数据导出成 EXCEL
    jsp自定义标签
    java生成验证码
    文字对齐格式
    css阴影效果
  • 原文地址:https://www.cnblogs.com/xueda120/p/3071010.html
Copyright © 2011-2022 走看看