This question requires write function, determine whether a given string of characters is "palindrome." The so-called "palindrome" refers to read and read backwards along the same string. Such as "XYZYX" and "xyzzyx" is a palindrome.
Interface definition function:
BOOL Palindrome (char * S);
Palindrome function determines whether the input string char * s palindrome. If it returns true, otherwise false.
Referee test sample program:
#include <stdio.h>
#include <string.h>
#define MAXN 20
typedef enum {false, true} bool;
bool palindrome( char *s );
int main()
{
char s[MAXN];
scanf("%s", s);
if ( palindrome(s)==true )
printf("Yes\n");
else
printf("No\n");
printf("%s\n", s);
return 0;
}
/ * Your code will be embedded here * /
Sample Input 1:
thisistrueurtsisiht
Output Sample 1:
Yes
thisistrueurtsisiht
Sample Input 2:
thisisnottrue
Output Sample 2:
No
thisisnottrue
bool palindrome( char *s )
{
int judge = 1;
int i, j;
j = strlen(s) - 1;
for (i = 0; i <= j; i++,j--)
{
if (s[i] != s[j])
judge = 0;
}
if (judge == 1)
return true;
else
return false;
}