hiho-1015(c++)
来源:互联网 发布:网上怎么开淘宝 编辑:程序博客网 时间:2024/06/06 09:05
20150204
KMP算法
字符串匹配
代码:
#include <iostream>using namespace std;string mode;string source;int next[10000];int counts;int main(){ int n; cin >> n; for(int i = 0; i < n; i++){ cin >> mode >> source; counts = 0; for(int k = 1; k < mode.length(); k++){ if(mode[k]==mode[counts]){ counts++; }else{ counts = 0; if(mode[k]==mode[counts]){ counts++; } } next[k] = counts; } counts = 0; int n = 0; for(int j = 0; j < source.length(); j++){ if(source[j]==mode[counts]){ counts++; if(counts == mode.length()){ n++; counts = next[counts-1]; } }else{ if(counts == 0) continue; j--; counts = next[counts-1]; } } cout << n << endl; } return 0;}
0 0
- hiho-1015(c++)
- hiho-1014(c++)
- hiho-1082(c++)
- hiho一下1015
- [Hiho]1015-KMP算法
- hiho #1015 : KMP算法
- hiho 1015 KMP算法
- hiho 1015 KMP
- hiho#1015 : KMP算法
- hiho-1015- KMP算法
- hiho~
- hiho hiho一下第三周 #1015 : KMP算法
- hiho 1015 : 提交补卡
- hiho Coder hiho字符串
- hiho一下 第三周 Hiocoder #1015 : KMP算法
- hiho一下第3周#1015 : KMP算法
- hiho#1015 : KMP算法(求子串出现的个数)
- HIHO code 1015 KMP算法 【KMP OR EXMP】
- NYOJ字符串右移
- C#+arcengine实现栅格计算器的减功能(可以用来修改栅格数据的高程)
- 如何优化cocos2d程序的内存使用和程序大小:第一部分
- laravel大型项目系列教程(四)之显示文章列表和用户修改文章
- Win10安全特性之执行流保护
- hiho-1015(c++)
- HP-UX top命令用法
- 获取 UIWebview 的 Useragent,以及附加自定义字段到 Useragent
- 牛腩新闻发布系统——解惑:VS2012验证码加载不出来
- Java 日期加减 该当日期是所在月的第几周 所在月的最后一天
- POJ-3090-Visible Lattice Points 解题报告
- CentOS - 系统管理(2)
- Android的onLayout、layout方法讲解
- 大型网站架构改进历程:存储的瓶颈(四)