字符串匹配算法

1.前綴蠻力匹配算法(linux內核string.h)html

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算法linux

  關於什麼是KMP算法:字符串匹配的KMP算法算法

3.PM算法spa

相關文章
相關標籤/搜索