[HDU] [2029] Palindromes _easy version

Problem Description

Loading...

Problem Analysis

Another pretty interesting palindrome problem.

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
#include<string.h>
int main() {
	int i,n,l;
	char s[10000];
	scanf("%d",&n);
	while(n) {
		scanf("%s",s);
		l=strlen(s);
		for(i=0;i<(l/2); i++)
			if(s[i]!=s[l-1-i])
				break;
		if(i==(l/2))
			printf("yes\n");
		else
			printf("no\n");
		n--;
	}
	return 0;
}
This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...