前言:
21考研,正在啃《算法笔记》,不论能否进复试记录一下准备路上写下的垃圾代码。
解答:
#include<cstdio>
const int max=260;
int main()
{
char str[max];
int len=0,p=0,tag=1;
for(int i=0;i<max;i++)
str[i]=NULL;
while(scanf("%s",str)!=EOF){
for(int i=0;i<max;i++)
if(str[i]==NULL)
break;
else
len++;
while(p<len){
if(str[p]!=str[len-1]){
printf("NO\n");
tag=0;
break;
}
else{
p++;
len--;
}
}
if(tag)
printf("YES\n");
for(int i=0;i<max;i++) //全部重新初始化一遍,还挺麻烦的
str[i]=NULL;
tag=1;
len=0;
p=0;
}
return 0;
}