A - Mike and palindrome
题目链接:
https://vjudge.net/contest/162220#problem/A
题解:
1.水题
2.前后对称扫描,不同++
3.分奇偶
AC code:
#include <stdio.h>
#include <string.h>
int main()
{
char a[30];
int i,n,num=0;
scanf("%s",a);
n=strlen(a);
for(i=0;i<=n-1-i;++i)
{
if(a[i]!=a[n-1-i])
{
num++;
}
if(num>1)
{
break;
}
}
if(n%2==1&&(num==0||num==1))
{
printf("YES\n");
}
else
{
if(num==1)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
return 0;
}