zoukankan      html  css  js  c++  java
  • 杭电2029--Palindromes _easy version(回文串)

    Palindromes _easy version

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 27492    Accepted Submission(s): 16699


    Problem Description
    “回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。请写一个程序判断读入的字符串是否是“回文”。
     
    Input
    输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。
     
    Output
    如果一个字符串是回文串,则输出"yes",否则输出"no".
     
    Sample Input
    4
    level
    abcde
    noon
    haha
     
    Sample Output
    yes
    no
    yes
    no
     
    Author
    lcy
     
    Source
     
    Recommend
    lcy   |   We have carefully selected several similar problems for you:  1040 2501 1106 1170 2123 
     
    题意:判断字符串是否为回文串
     1 #include <stdio.h>
     2 #include <string.h>
     3 char str[1010] ;
     4 int main()
     5 {
     6     int n ;
     7     scanf("%d", &n) ;
     8     while(n--) 
     9     {
    10         getchar() ;
    11         int len, i, j ;
    12         scanf("%s", str);
    13         len = strlen(str) ;
    14         for(i=0,j=len-1; i<len; i++,j--)
    15         {
    16             //printf("%c %c
    ",str[i], str[j]) ;
    17             if(str[i] != str[j])
    18             break ;
    19         }
    20         if(i == len)
    21         printf("yes
    ") ;
    22         else
    23         printf("no
    ") ;
    24     }
    25     return 0 ;
    26 } 
  • 相关阅读:
    响应式开发
    css3的2D和3D的转换
    前端CSS3笔记
    DOM精简版笔记
    JS进阶
    linux 修改时间同步到BIOS
    linux-设置代理和取消代理
    linux-rpm强制安装跳过依赖包
    [linux] VNC the connection was refused by the computer
    Linux vim 常用命令(不定时update)
  • 原文地址:https://www.cnblogs.com/soTired/p/4380519.html
Copyright © 2011-2022 走看看