摘要: public static int Sunday(string text, string pattern) { int i, j, m, k; i = j = 0; int tl, pl; ... 阅读全文
posted @ 2013-12-10 14:43 飘渺峰 阅读(697) 评论(0) 推荐(0) 编辑
摘要: static void BuildTable(string subString, ref int[] next) { if (string.IsNullOrWhiteSpace(subString)) return; int j = 0, k = -1; next[0] = -1; while (j /// 查找算法 /// /// 要搜索的字符串 /// 子串 /// 子串在source字符串中的开始位... 阅读全文
posted @ 2013-12-10 14:40 飘渺峰 阅读(1340) 评论(1) 推荐(0) 编辑
摘要: 因项目需要使用字符串查询算法,在网上搜搜了半天,没有找到C#版的。索性根据BM机制,用C#实现了一遍。现在贴出了,以备忘记。 1 /// 2 /// BM算法 3 /// 4 /// 5 /// 6 /// 7 static int BoyerMooreSearch(string source, string subString) 8 { 9 if(string.IsNullOrWhiteSpace(source) || string... 阅读全文
posted @ 2013-12-10 14:33 飘渺峰 阅读(1048) 评论(3) 推荐(1) 编辑