zoukankan      html  css  js  c++  java
  • HDU-2029

    Palindromes _easy version

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


    Problem Description
    “回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。请写一个程序判断读入的字符串是否是“回文”。
     
    Input
    输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。
     

    Output

    如果一个字符串是回文串,则输出"yes",否则输出"no". 
    Sample Input
    4
    level
    abcde
    noon
    haha
     
    Sample Output
    yes
    no
    yes
    no
     1 #include<stdio.h>
     2 #include<stdlib.h>
     3 #include<math.h>
     4 #include<iostream>
     5 #include<string.h>
     6 #include<algorithm>
     7 using namespace std;
     8 int main()
     9 {
    10     int n;
    11     char s[1000];
    12     char srev[1000];
    13     scanf("%d",&n);
    14     getchar();
    15     while (n--)
    16     {
    17         gets(s);
    18         strcpy(srev,s);
    19         strrev(srev);
    20         if (!strcmp(srev,s)) printf ("yes
    ");
    21         else printf("no
    ");
    22     }
    23     return 0;
    24 }
  • 相关阅读:
    python知识合集
    可拖动的DIV
    JavaScript创建对象
    JavaScript prototype
    CSS media queries
    JavaScript作用域链
    JavaScript包装对象
    贫下中农版jQuery
    JavaScript 命名空间
    z-index 应用简单总结
  • 原文地址:https://www.cnblogs.com/leiyuxiang/p/3495654.html
Copyright © 2011-2022 走看看