字符串匹配算法有很多种,最为常用的有KMP算法、普通算法。
1、普通算法:此算法是效率最低的算法,时间复杂度为O(NM)。
程序如下:
bool str_match(const char * str1, const char * str2)//O(P*T)
{
assert(str1 != NULL && str2 != NULL);
int k = 0;
for (unsigned ...
分类:
其他好文 时间:
2014-10-07 17:56:23
阅读次数:
132
设50元的人为+1 100元的人为-1 满足前任意k个人的和大于等于0 卡特兰数
C(n+m, m)-C(n+m, m+1)*n!*m!
import java.math.*;
import java.util.*;
public class Main {
/**
* @param args
*/
public static void main(Str...
分类:
其他好文 时间:
2014-10-07 00:43:11
阅读次数:
232
public static boolean includingNUM(String str)throws Exception{Pattern p = Pattern.compile("[\u4e00-\u9fa5]*[\\d|\\w]+[\u4e00-\u9fa5]*");//或者 Pattern ...
分类:
编程语言 时间:
2014-10-06 23:11:51
阅读次数:
262
1 package observer; 2 3 import java.lang.reflect.Method; 4 5 import oracle.net.aso.c; 6 7 public class Test { 8 9 public static void main(Str...
分类:
编程语言 时间:
2014-10-06 21:46:00
阅读次数:
242
一、strcat()与strncat()
strcat():strcat(dest,src); strcat把src所指向的字符添加到dest结尾处(覆盖原dest结尾处的'\0'),并添加新的'\0'。
说明:src和dest所指内存区域不可以重叠,并且dest必须有足够的空间来容纳src的字符串,返回指向dest的指针。
str...
分类:
其他好文 时间:
2014-10-06 18:59:20
阅读次数:
192
#includeusing namespace std;int main(){ //memcpy函数 char d[20]; //声明数组 char *str="Hellow word"; memcpy(d,str,strlen(str)); d[strlen(str)]=0; //末尾添加0 表示...
分类:
其他好文 时间:
2014-10-06 17:28:00
阅读次数:
221
SQLAlchemy报ProgrammingError:Youmustnotuse8-bitbytestringsunlessyouuseatext_factorythatcaninterpret8-bitbytestrings错误python2.x中最讨厌的就是编码问题了,写下来以备后用。解决方法:1.开头加上:#encoding:utf-82.尝试把字符转化为unicode格式unicode(str_name)这种..
分类:
数据库 时间:
2014-10-06 15:55:40
阅读次数:
898
很久没有做BC了,这次又是悲剧,1002到死都是WA,题目意思误解了,而且最后还忽略了一个问题就是如果len==1 && str[0] == '-' 的情况。。悲剧致死。HDU 5058 - So easy ( 这尼玛真的so easy )我直接用了set,然后遍历。。后来发现,,,,集合直接相等不...
分类:
其他好文 时间:
2014-10-06 01:57:49
阅读次数:
300
1 责任链1 package com.alvin;2 3 public interface Filter {4 public String doFilter(String str);5 }1 package com.alvin;2 3 public class HtmlFilter impl...
分类:
其他好文 时间:
2014-10-05 23:56:09
阅读次数:
281
页面编码方式为utf-8当使用post传值时request.setContentType("utf-8");当使用get传值时String str = request.getParameter("str");str = new String(str.getBytes("iso-8859-1"),"u...
分类:
其他好文 时间:
2014-10-05 23:31:29
阅读次数:
203