您的位置:首页 > 其它

CodeForces 625B - War of the Corporations

2016-03-15 22:52 495 查看
字符串匹配

#include <cstdio>
#include <iostream>
#include <cstring>

const int MAX = 1e5 + 5;
char arr1[MAX], arr2[35];

int main()
{
scanf("%s%s", arr1, arr2);
int lenth1 = strlen(arr1), lenth2 = strlen(arr2), cnt = 0;
for (int i = 0; i < lenth1; ++i)
{
int tmp = i;
for (int j = 0; j < lenth2; ++j)
{
if (arr1[tmp] != arr2[j])
{
break;
}
++tmp;
if (j == lenth2 - 1)
{
cnt++;
i = tmp - 1;
}
}
}

printf("%d\n", cnt);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: