HDU-2029

#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	char s[50];
	cin.ignore();
	while(n--){
		gets(s);
		int m =strlen(s);
		int i=0,l=0,r=m-1;//record the position left and right of the array
		if(m==2){
			if(s[0]==s[1])
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}else{
			for(;i<m/2;i++){
				if(s[l] == s[r]){
					r--;
					l++;
				}
			}
			if( l == r || l-1 == r){
				cout<<"yes"<<endl;
			}else{
				cout<<"no"<<endl;
			}
		}

	} 

	return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章