数据结构 基于BF和KMP的串模式匹配算法设计与实现.docVIP

  • 5
  • 0
  • 约2.14千字
  • 约 4页
  • 2019-10-26 发布于广东
  • 举报

数据结构 基于BF和KMP的串模式匹配算法设计与实现.doc

实验④:基于BF和KMP的串模式匹配算法设计与实现 (1)BF算法 Demo4_1(BF).exe 实验源程序代码: // Demo_4.cpp : Defines the entry point for the console application. // #include stdafx.h #includestdio.h #includestring.h #includestdlib.h #define MaxSize 100 //串的存储表示 typedef struct { char str[MaxSize]; }String; //BF的串模式匹配算法设计与实现 int BFIndex(String S, int pos, String T) { int i = pos; int j = 0; while(i =strlen(S.str) j=strlen(T.str)) { if(S.str[i-1] == T.str[j])//数组下标从0开始 { i++; j++; } else { i = i-j+1; j = 0; } } if (j==strlen(T.str)) { return (i-strlen(T.str)); } else retur

文档评论(0)

1亿VIP精品文档

相关文档