Codeup cemetery - Problem I: palindrome string [string]

Title Description

Read a string of characters, whether or not palindromic sequence. "Palindrome string" is a positive reading and verlan same string, such as "level" or "noon" and so is a palindrome string.

Entry

His string length does not exceed 255.

Export

If the string is a palindrome, output "YES", otherwise a "NO".

Sample input

12321

Sample Output

YES
#include <stdio.h>
#include <string.h>
int main()
{
    int i;
    char str[256];
    scanf("%s",str);    //读入字符串
    for(i=0; i<strlen(str)/2; i++)   //判断字符串的一半
    {
        if(str[i]==str[strlen(str)-1-i])  
            continue;
        else
            break;
    }
    if(i!=strlen(str)/2)   //判断是否都匹配成回文
        printf("NO\n");  
    else
        printf("YES\n");

    return 0;
}

operation result:

Published 462 original articles · won praise 55 · views 320 000 +

Guess you like

Origin blog.csdn.net/LY_624/article/details/88857073