[恢]hdu 2163

2011-12-15 02:48:00

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2163

题意:判断是否是回文。。。

代码:

# include <stdio.h>
# include <string.h>


int test(char str[])
{
int i, len = strlen(str) ;
for (i = 0 ; i < len/2 ; i++)
if (str[i] != str[len-1-i]) return 0 ;
return 1 ;
}


int main ()
{
int nCase = 1 ;
char str[60] ;
while (gets (str))
{
if (strcmp(str, "STOP")==0) break ;
printf ("#%d: %s\n", nCase++, test(str) ? "YES" : "NO") ;
}
return 0 ;
}



posted @ 2012-01-06 15:02  Seraph2012  阅读(193)  评论(0编辑  收藏  举报