예제 #1
0
파일: kmp-test.c 프로젝트: fkolacek/FIT-VUT
int main (int argc, char *argv[])
{
  if (argc != 3) {
    printf("Really? Even in test?\n");
    return 1;
  }

  mmuInit();
  tString text = strCreate(argv[1]);
  tString search = strCreate(argv[2]);

  printf("Text: %s\n"
         "Text len: %u\n", text.data, text.len);
  printf("Hledany string: %s\n"
         "Hledany len: %u\n", search.data, search.len);
  int position = kmpSearch(text, search);
  printf("Pozice je: %d\n", position);

  strFree(&text);
  strFree(&search);

  mmuGlobalFree();

  return 0;
}
예제 #2
0
파일: string_match.cpp 프로젝트: mseln/nat
int main(){
    strcpy(T, "asdhasdhejasdasdhejasdasd");
    strcpy(P, "hej");
    
    n = 25; m = 3;

    kmpPreprocess();
    kmpSearch();

    return 0;
}
예제 #3
0
파일: filesearch.c 프로젝트: Leggy/udoodev
/* Returns the number of occurances of the pattern in the text. */
size_t subSearch(char* text, const char* pattern) {
    size_t occurances = 0;
    char* temp = text;
    size_t index = 0;
    
    while ((index = kmpSearch(temp, pattern)) != strlen(temp)) {
        occurances += 1;
        if (strlen(pattern) + index >= strlen(temp)) {
            break;
        } else {
            temp += strlen(pattern) + index;
        }
    }
    return occurances;
}
예제 #4
0
파일: library.c 프로젝트: fkolacek/FIT-VUT
/**
 * @info      Fce hleda podretezec v retezci
 * @param   tSymbolData - retezce, v prvnim se hleda, druhy se hleda v prvnim
 * @return  tSymbolData - vrati pozici v prvnim stringu, na ktere nasel druhy string
 */
void find (tSymbolData *dest, tSymbolData *text, tSymbolData *searched)
{
  if (text == NULL || searched == NULL) return;
  dest->type = DT_NUMBER;
  dest->data.dData = (double) kmpSearch(text->data.sData, searched->data.sData);
}