//判断一个字符串是不是回文字符串 #include <stdio.h> #include <assert.h> int panduan( char *p ) { char *q ; assert( *p != NULL ); q = p; while( *p != '\0') { p++; } p--; while(*q != '\0') { if( *p == *q) { p--; q++; } else return -1; } return 1; } int main() { char p[] = "12321"; printf("%d\n",panduan(p)); return 0; }
时间: 2024-11-03 20:47:45