字符串匹配算法

1.前缀蛮力匹配算法(linux内核string.h)

char* strstr(const char *s, const char *wanted) 

{    

    const size_t len = strlen(wanted);     

    if (len == 0) return (char *)s;     

    while (*s != *wanted || strncmp(s, wanted, len))        

        if (*s++ == '\0')            

             return (char *)NULL;     

    return (char *)s; 

}

 

2.KMP算法

  关于什么是KMP算法:字符串匹配的KMP算法

3.PM算法

你可能感兴趣的:(字符串)