[恢]hdu 2087

2011-12-20 03:27:09

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

题意:中文。直接枚举。

代码:

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


char s1[1010], s2[1010] ;


int find(char *s1, char *s2)
{
int i ;
for (i = 0 ; s2[i] ; i++)
if (s1[i] != s2[i]) return 0 ;
return 1 ;
}


int main ()
{
int i, len1, len2, cnt ;
while (2 == scanf ("%s%*c%s%*c", s1, s2))
{
len1 = strlen(s1) ;
len2 = strlen(s2) ;
cnt = 0 ;
for (i = 0 ; i < len1 ; i++)
{
if(find(s1+i, s2))
{
cnt++ ;
i+= len2-1 ;
}
}
printf ("%d\n", cnt) ;
}
}



posted @ 2012-01-06 22:38  Seraph2012  阅读(133)  评论(0编辑  收藏  举报