title address:http://www.codeup.cn/problem.php?cid=100000580&pid=8
Title Description:
Read a string of characters to determine if it is a palindrome string. "Palindrome string" is a literal reading and anti-read all the same string, such as "level" or "noon" and so on is a palindrome string.
Input:
A line of string, not exceeding 255 length.
Output:
If it is a palindrome string, output "YES", otherwise output "NO".
Sample Input:
12321
Sample output:
YES
The complete code is as follows:
#include <cstdio> #include <cstring> const int MAXN = 256; Determine if the string str is "palindrome string" bool Judge (char str[]) {int len = strlen (str); string length for (int i = 0; i < LEN/2; i++) {//I enumeration string first half if (str[i]! = str[len-1-i]) {Retu RN false; Not "Palindrome string"}} return true;
Is "palindrome string"} int main () {char STR[MAXN]; while (gets (str)) {//input string BOOL flag = Judge (str); Determine if the string str is "palindrome string" if (flag = = True) {//"palindrome" printf ("yes\n");//Output YES}else{ Not "palindrome" printf ("no\n");
Output NO}} return 0; }