c语言----回文,请帮我查看一下怎么错了,为什么输入不是回文的时候,也显示yes

来源:百度知道 编辑:UC知道 时间:2024/04/29 00:39:29
#include <stdio.h>
#include <string.h>
main()
{char s[90];
int i,j;
gets(s);
for(i=0,j=strlen(s)-1;i<strlen(s)/2;i++,j--)
if(s[i]!=s[j])
break;
if(i=strlen(s)/2)
printf("yes");
else
printf("no");
}
但改成if(i==strlen(s)/2)还是没有用呀

if(i=strlen(s)/2)改成if(i==strlen(s)/2)

#include <stdio.h>
#include <string.h>
main()
{char s[90];
int i,j;
gets(s);
for(i=0,j=strlen(s)-1;i<strlen(s)/2;i++,j--)
if(s[i]!=s[j])
break;
if(i==strlen(s)/2)
printf("yes");
else
printf("no");
getch();}