zoukankan      html  css  js  c++  java
  • TZOJ Start

    描述

    After the Online Round contest, we believe that you have already known how to write programs in ACM contest.
    For example, here‟s the analysis code of “A+B” problem.


    Now after the start, you are supposed to do another easy problem.
    For a string S, write a program to check whether it is a palindromic string.

    Palindromice srings are strings that read the same forwards as backwards such as "abcba".                                                                                 

    输入

    There are multiple test cases.
    For each case, the first line contains one integer n indicating the length of the string. And the second line contains a n-length string as described above.

    1 <= n <= 100,000, the string may only contains lower case letters.

    输出

    For each case, print “YES” if the string is a palindromic or “NO” otherwise.

    样例输入

    3
    aba
    4
    qwer

    样例输出

    YES
    NO

    回文是个好东西呐

    #include <stdio.h>
    
    int main()
    {
        int n,j,i;
        char a[100001];
        while(~scanf("%d",&n))
        {
            getchar();    
            for(i=0;i<n;i++)
            {
                scanf("%c",&a[i]);
            }
            for(i=0,j=n-1;i<=(n-1)/2;i++,j--)
            {
                if(a[i]!=a[j])
                    break;
            }
            if(i>j)
                printf("YES
    ");
            else 
                printf("NO
    ");
         } 
    }
  • 相关阅读:
    Nginx的Mainline version、Stable version、Legacy version的版本区别
    十个程序员必备的网站推荐
    各大OJ题目分类
    ubuntu 12 安装bcm 43142无线网卡驱动
    unp.h
    Linux优秀软件整理
    陈皓一起写Makefile 概述
    开源资源目录
    (三)鸟哥Linux读书笔记
    CSS3实现选项卡
  • 原文地址:https://www.cnblogs.com/andrew3/p/12721907.html
Copyright © 2011-2022 走看看