用C语言判断字符串是否为回文

时间:2026-02-14 11:41:23

1、进入VC++,新建C++文件。

2、编写程序:

#include <stdio.h>

void main()

{

char a[100];

int i=0,j=0;

printf("Please input string:");

gets(a);

while(a[i]!='\0')

i++;

i--;

for(;j<=i;i--,j++)

{

if(a[i]!=a[j])

break;

}

if(j<=i)

printf("%s is not a palindrome\n",a);

else

printf("%s is a palindrome\n",a);

}

用C语言判断字符串是否为回文

3、检查没有错误进行编辑连接运行:

用C语言判断字符串是否为回文

© 2026 五度知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com