求子串位置的定位函数
2014-05-21 10:20
225 查看
package test1; public class test2 { public static int index(char[] s,char[] t,int pos) { int i=pos; int j=0; while (i<s.length && j<t.length) { if (s[i]==t[j]) { ++i; ++j; } else { i=i-j+1; j=0; } } if (j>=t.length) { return i-t.length; } else return 0; } public static void main(String[] args) { String S="asdffwrewrew"; char[] s1=S.toCharArray(); String T="ew"; char[] t1=T.toCharArray(); System.out.println(index(s1, t1, 0)); } }
相关文章推荐
- 串的模式匹配算法(求子串位置的定位函数Index(S,T,pos))
- 串的模式匹配算法(求子串位置的定位函数,适合一般字符串定位)
- 求子串位置的定位函数(C语言版)
- 巧用backtrace系列函数,在不具备gdb环境的Linux系统上大致定位段错误位置
- 在不具备gdb环境的类Linux系统开发板上调试段错误,大致定位出错函数位置
- 如何定位Release 版本中程序崩溃的位置 ---利用map文件 拦截windows崩溃函数
- 学习stdio.h提供的位置指针重定位函数
- vim使用—移动到文件开始和结束位置和当前位置(gg,G)、快速定位到当前光标所在变量或函数的定义处(gd)、自动对齐C和C++程序(先gg再=再G)、自动补全变量名,函数名和字符串ctrl+n或ct
- 《Delphi 算法与数据结构》学习与感悟[5]: 定位一个字符位置时, Pos 函数为什么不是最快的?
- 如何定位Release 版本中程序崩溃的位置 ---利用map文件 拦截windows崩溃函数
- 如何定位Release 版本中程序崩溃的位置 ---利用map文件 拦截windows崩溃函数
- 巧用backtrace系列函数,在不具备gdb环境的Linux系统上大致定位段错误位置
- 巧用backtrace系列函数,在不具备gdb环境的Linux系统上大致定位段错误位置
- 定位Release 版本中程序崩溃的位置 ---利用map文件 拦截windows崩溃函数
- js调试-定位到函数所在文件位置
- 巧用backtrace系列函数,在不具备gdb环境的Linux系统上大致定位段错误位置
- 使用FUNCNAME 和BASH_LINENO实现shell脚本中定位函数错误在代码中的位置
- 巧用backtrace系列函数,在不具备gdb环境的Linux系统上大致定位段错误位置
- 如何在Linux ELF格式的文件(可执行binary,以及so文件)中定位到对应的函数位置
- vim使用—移动到文件开始和结束位置和当前位置(gg,G)、快速定位到当前光标所在变量或函数的定义处(gd)、自动对齐C和C++程序(先gg再=再G)、自动补全变量名,函数名和字符串ctrl+n或ct