HDOJ  2029   Palindromes _easy v…

来源:互联网 发布:ubuntu安装qq拼音 编辑:程序博客网 时间:2024/05/20 02:25

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

#include<iostream>
#include<string.h>
using namespace std;
int f(char a[])
{
 int i=0,n=strlen(a);
 while(a[i]==a[n-i-1]&&i<n/2)
    i++;
 return a[i]==a[n-i-1];
}
int main()
{
 int T;
 cin>>T;
 getchar();
 while(T--)
 {
  char a[1000];
  gets(a);
  if(f(a))cout<<"yes"<<endl;
  elsecout<<"no"<<endl;
 }
 return 0;
}
 

0 0
原创粉丝点击