#include
int main()
{
char s[270];
gets(s);
int i,j,y=0;
if(strlen(s)%2!=0)
{
for(i=0,j=strlen(s);i<(strlen(s)+1)/2;i++,j--)
{
if('s[i]'=='s[j]')//为什么这里判断不了两个字符相等
y++;
printf("*");
}
printf("%d",y);//输出y 一直为0
}
else
{
printf("N");
}
}
#include "stdio.h"
#include "string.h"
int main()
{
char s[270];
gets(s);
int i,j,y=0;
if(strlen(s)%2!=0)
{
for(i=0,j=strlen(s)-1;i<(strlen(s)+1)/2;i++,j--)
{
if(s[i]==s[j])//为什么这里判断不了两个字符相等
y++;
printf("*");
}
printf("%d",y);//输出y 一直为0
}
else
{
printf("N");
}
}
#include<stdio.h>
#include<string.h>
int main()
{
char a[100];
int n,count=0,i;
scanf("%s",a);
n=strlen(a);
for(i=0;i<n/2;i++)
{
if(a[i]==a[n-i-1])count++;
}
if(count==n/2)printf("YES\n");
else printf("NO\n");
}
这个我写出来是可以的你试试看?