Analyzing the C language function palindrome

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_43669941/article/details/86566236
int fun(char *p) {
    int i=0, j=0;
    j = strlen(p) - 1;
    while(p[i]==p[j] && i<=j) {
        i++;
        j--;
    }
    if(i>j) {
        return 1;//此时为回文序列
    } else {
        return 0;//此时不为回文序列   
    }
}

 

Guess you like

Origin blog.csdn.net/weixin_43669941/article/details/86566236