`
com_xpp
  • 浏览: 352986 次
社区版块
存档分类
最新评论

Binary String Matching

 
阅读更多

/*日期:2011-10-13
作者:xiaosi
题目:Binary String Matching
*/
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
while(n--)
{
int i,j,k,len_a,len_b,count=0;
string a,b;
cin>>a;cin>>b;
len_a=a.length();
len_b=b.length();
for(j=0;j<len_b;j++)
{
k=j;
for(i=0;i<len_a;i++,k++)
{
if(a[i]!=b[k])
{
break;
}
}
if(i==len_a)
{
count++;
}
}
printf("%d\n",count);
}
}
return 0;
}

分享到:
评论

相关推荐

    Tries and String Matching - Slides - 2009 (Small09)-计算机科学

    ● Red/black trees ≡ 2-3-4 trees, binomialheaps ≡ binary numbers, etc.● Amortized Analysis ● Aggregate, banker's, and potential methods.Where We're Going● String Data Structures ● Data ...

    常用算法(python)

    素字符串匹配算法(Naive String Matching) KMP 算法(Knuth-Morris-Pratt) Rabin-Karp 算法 Boyer-Moore 算法 A* 搜索算法 Dijkstra 算法 Bellman-Ford 算法 Floyd-Warshall 算法 Kruskal 算法 Prim 算法 Edmonds...

    The Algorithm Design Manual (2rd Edition)

    8.2 Approximate String Matching 8.3 Longest Increasing Sequence 8.4 War Story: Evolution of the Lobster 8.5 The Partition Problem 8.6 Parsing Context-Free Grammars 8.7 Limitations of Dynamic ...

    麻省理工算法导论(完整精辟版)

    Chapter 32 - String Matching Chapter 33 - Computational Geometry Chapter 34 - NP-Completeness Chapter 35 - Approximation Algorithms Part VIII - Appendix: Mathematical Background Appendix A ...

    【麻省理工大学】算法导论

    Chapter 32 - String Matching Chapter 33 - Computational Geometry Chapter 34 - NP-Completeness Chapter 35 - Approximation Algorithms Part VIII - Appendix: Mathematical Background Appendix A ...

    cpp-算法精粹

    Construct Binary Tree from Inorder and Postorder Traversal 二叉查找树 Unique Binary Search Trees Unique Binary Search Trees II Validate Binary Search Tree Convert Sorted Array to Binary Search Tree ...

    LuaUnicode icu-lua

    But see the sections below on pattern matching and string equality. Unicode Lua programs Literal Unicode strings can appear in your lua programs. Either a UTF-8 encoded string can appear directly ...

    Wrox.Beginning.Algorithms.Nov.2005.pdf

    * Algorithms for string searching, string matching, hashing, and computational geometry * How to use test-driven development techniques to ensure your code works as intended * How to dramatically ...

    [麻省理工学院-算法导论](英文版).chm

    Chapter 32 - String Matching Chapter 33 - Computational Geometry Chapter 34 - NP-Completeness Chapter 35 - Approximation Algorithms Part VIII - Appendix: Mathematical Background Appendix A ...

    Introduction to Algorithms, 3rd edtion

    32.3 String matching with finite automata 995 32.4 The Knuth-Morris-Pratt algorithm 1002 33 Computational Geometry 1014 33.1 Line-segment properties 1015 33.2 Determining whether any pair of segments ...

    算法导论 第三版 英文原版 高清文字版

    32.3 String matching with finite automata 995 ? 32.4 The Knuth-Morris-Pratt algorithm 1002 33 Computational Geometry 1014 33.1 Line-segment properties 1015 33.2 Determining whether any pair of ...

    算法导论-introduction to algrithms 3rd edition

    32.3 String matching with finite automata 995 ? 32.4 The Knuth-Morris-Pratt algorithm 1002 33 Computational Geometry 1014 33.1 Line-segment properties 1015 33.2 Determining whether any pair of ...

    算法导论(英文第2版)

    Chapter 32 - String Matching Chapter 33 - Computational Geometry Chapter 34 - NP-Completeness Chapter 35 - Approximation Algorithms Part VIII - Appendix: Mathematical Background Appendix A ...

    Mastering Algorithms with Perl

    Written for readers with at least some Perl ... string matching and parsing, 2-D geometry, number systems, cryptography (including DES and RSA), probability, statistics, and numerical analysis.

    算法导论英文版

    32.3 String matching with finite automata 916 32.4 The Knuth-Morris-Pratt algorithm 923 33 Computational Geometry 933 33.l Line--segment properties 934 33.2 Determining whether any pair of segments ...

    [麻省理工学院-算法导论].Introduction.to. Algorithms,.Second.Edition

    Chapter 32 - String Matching Chapter 33 - Computational Geometry Chapter 34 - NP-Completeness Chapter 35 - Approximation Algorithms Part VIII - Appendix: Mathematical Background Appendix A ...

    算法导论--Introduction.to.Algorithms

    from classical algorithms in graph theory to special algorithms for string matching, computational geometry, and number theory. The revised third edition notably adds a chapter on van Emde Boas trees...

    leetcode是收费的吗-Node-Search-Algorithms:基于众所周知的算法制作的Node.js和javascript搜索库,

    leetcode是收费的吗 ...Binary Search Tree Search Genetic Algorithm Combinatorial optimization Hashing Internet search algorithms Metaheuristics String matching algorithms Linear Search Binar

Global site tag (gtag.js) - Google Analytics