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\n");
		else 
			printf("NO\n");
 	} 
}



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值