26 lines
497 B
C
26 lines
497 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "kmp.h"
|
|
#include "util.h"
|
|
|
|
|
|
int main() {
|
|
char *patter = "acabacacd";
|
|
char *text = "acfacabacabacacdac";
|
|
|
|
int pattern_len = strlen(patter);
|
|
|
|
// long proper suffix array
|
|
int lps[pattern_len];
|
|
|
|
create_lps(patter, pattern_len, lps);
|
|
|
|
int match_number = 0;
|
|
int residue;
|
|
|
|
int *matches = search_pattern(text, patter, lps, &match_number, &residue);
|
|
|
|
print_array(matches, match_number);
|
|
printf("%d\n", residue);
|
|
}
|