hdu2087(剪花布条)

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

15103806_ytUl.gif 15103806_Amui.gif View Code

    
#include < iostream >
using namespace std;
int main()
{
char a[ 1001 ],b[ 1001 ];
int i,j;
while (cin >> a)
{
if (a[ 0 ] == ' # ' ) break ;
cin
>> b;
int L1 = strlen(a);
int L2 = strlen(b);
int sign = 0 , flag = 0 ;
i
= sign,j = 0 ;
while (i < L1)
{
if (a[i] == b[j])
{
i
++ ;
j
++ ;
if (j == L2)
{
flag
++ ;
j
= 0 ;
sign
= i;
}
}
else
{
j
= 0 ;
sign
++ ;
i
= sign;
}
}
cout
<< flag << endl;
}
return 0 ;
}

转载于:https://my.oschina.net/garyun/blog/602916

猜你喜欢

转载自blog.csdn.net/weixin_33984032/article/details/91774170