Binary String Matching
生活随笔
收集整理的這篇文章主要介紹了
Binary String Matching
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Binary String Matching
描述
Given two strings A and B, whose alphabet consist only ‘0’ and ‘1’. Your task is only to tell how many times does A appear as a substring of B? For example, the text string B is ‘1001110110’ while the pattern string A is ‘11’, you should output 3, because the pattern A appeared at the posit
輸入?
#include <iostream> #include <string>using namespace std;int main() {int n;cin>>n;while(n--){string strA;string strB;int count = 0;cin>>strA;cin>>strB;int A = strA.size();int B = strB.size();for(int i=0; i<B; i++){if(strB.substr(i, A) == strA)count ++;}cout<<count<<endl;}return 0; }?
總結(jié)
以上是生活随笔為你收集整理的Binary String Matching的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第四章、epub文件处理 -- epub
- 下一篇: Excel2003怎样拆分单元格