void Solve(char A[]) { int Alen = strlen(A), Blen = Alen; int i, j; for(i = 0, j = Blen-1; i < Alen; i++, j--) B[j] = A[i]; B[Blen] = '\0'; int tail = KMPMatching(A, B); for(i = Blen-1; i > tail; i--) printf("%c", B[i]); printf("%s\n", B); }
int main(void) { char mStr[_MAX_SIZE_]; char pStr[_MAX_SIZE_]; int i, position; printf("main string :"); scanf("%s", mStr); printf("pattern string:"); scanf("%s", pStr); printf("\n\n"); position = BruteForceMatching(mStr, pStr); // printf("position : %d\n", position); printf("BruteForceMatching:\n"); Print(mStr, pStr, position); position = KMPMatching(mStr, pStr); printf("KMPMatching:\n"); Print(mStr, pStr, position); return 0; }