标签:
3 11 1001110110 101 110010010010001 1010 110100010101011
3 0 3
原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=5
输入两个字符串,问你第二个字符串在第一个中出现了多少次,可重叠。
使用string 的find
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
string a,b;
int main()
{
int T;
//freopen("data/5.txt","r",stdin);
cin>>T;
while(T--)
{
cin>>a>>b;
int cnt=0;
//for (int index=0; (index=b.find(a,index))!=string::npos; index += 1,cnt++);
int index=0;
while((index=b.find(a,index))!=string::npos)
{
index++;
cnt++;
}
cout<<cnt<<endl;
}
return 0;
}
NYOJ 5 Binary String Matching【string find的运用】
标签:
原文地址:http://blog.csdn.net/hurmishine/article/details/52261820