KMP算法中核心的代码
2012-06-10 12:22
260 查看
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
void get_next(string T, int *next)
{
int i = 1, j = 0;
next[1] = 0;
while (i < atoi((char *)&T[0]))
{
//cout<<"i: "<<i<<" j:"<<j<<endl;
if (j == 0 || T[i] == T[j])
{
++i;
++j;
next[i] = j;
}
else
j = next[j];
}
}
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
void get_next(string T, int *next)
{
int i = 1, j = 0;
next[1] = 0;
while (i < atoi((char *)&T[0]))
{
//cout<<"i: "<<i<<" j:"<<j<<endl;
if (j == 0 || T[i] == T[j])
{
++i;
++j;
next[i] = j;
}
else
j = next[j];
}
}
相关文章推荐
- 看数据结构写代码(18) KMP算法
- Spark源码阅读笔记:Standalone模式集群核心角色代码浅析
- 用.net实现远程获取其他网站页面内容!(核心代码分析)
- Ajax技术--用于web的应用程序(基于Ajax的D版126信箱核心javascript代码)
- validate验证指定action的核心代码
- 基于visual c++之windows核心编程代码分析(27)保持程序单实例运行
- 基于visual c++之windows核心编程代码分析(34)WinIo驱动级模拟按键的实现
- 基于visual c++之windows核心编程代码分析(41)实现反向连接后门
- 小熊鼠标键盘模拟工具 使用说明 及核心代码
- 基于visual c++之windows核心编程代码分析(47)实现交换网络的QQ号嗅探
- 如何编写更棒的代码:11个核心要点
- 基于visual c++之windows核心编程代码分析(54)实现Winlogon注入dll
- Redis分布式锁核心代码
- 基于visual c++之windows核心编程代码分析(62)读取本地已登录的QQ号及应用代码
- 猫猫学IOS(四十一)UI之核心动画 两行代码搞定3D转场(做android的哭死)
- DTCC:MySQl核心代码开发经验揭示
- 前端架构设计1:代码核心
- 如何将自己代码的核心部分对用户“隐藏”起来,使用导入静态库。
- C++实现搜狗浏览器加速代理客户端(HTTP/HTTPS)的核心代码
- demo/regLogin核心代码分析