C语言笔试题(19)——判断字符串回文

来源:互联网 发布:自动化设备设计软件 编辑:程序博客网 时间:2024/04/30 05:35


#include <stdio.h>#include <assert.h>int str_test(char *str){    assert(str != NULL);    char *p_top = str;    char *p_end;    while (*++str != '\0')        ;    p_end = --str;    while (p_top <= p_end)    {        if (*p_top++ != *p_end--)            return 0;     }    return 1;}int main(int argc, const char *argv[]){    char str[] = "abcba";    printf("%d\n", str_test(str));    return 0;}


原创粉丝点击