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

2025-10-10 23:56:19

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语言判断字符串是否为回文

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢