zoukankan      html  css  js  c++  java
  • hdu 2029 Palindromes _easy version


    http://acm.hdu.edu.cn/showproblem.php?pid=2029

    这是一道回文串,以前我老是用for循环,不过今天试了试while觉得还挺好用的,呵呵,果断、一a了  。。好开心啊 ,今天有个好的开始不错哦!回文就是前面和后面一直匹配。。。若有不同的就跳出并且输出no,若一直到最后都没有不同就输出yes

    #include <stdio.h>

    #include <string.h>

    #include <stdlib.h>

    int main()

    {

        int n,m;

        char a[10002];

        scanf("%d",&n);

        while(n--)

        {

                  scanf("%s",a);

                  int k=strlen(a);

                  int  i=0,flag=0;

                  while(i<=k)

                  {

                            if(a[i]==a[k-1])

                            {

                                i++;k--;

                            }

                            if(a[i]!=a[k-1])

                            {

                                 flag=1;break;

                            }

                  }

                  if(flag)  puts("no");

                  else

                  puts("yes");

        }

       // system("pause");

        return 0;

    }

  • 相关阅读:
    Mybatis学习笔记2:第一个Mybatis使用实例
    Mybatis学习笔记1:Mybatis简介
    springcloud Eureka 服务注册与发现
    springcloud rest微服务案例
    springmvc返回json
    springboot 集成mybatisplus
    vue axios使用
    vue前后端交互方式
    day3
    D. Count the Arrays
  • 原文地址:https://www.cnblogs.com/yuelingzhi/p/2126309.html
Copyright © 2011-2022 走看看