Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   I dont know where is the error (http://www.go4expert.com/forums/i-dont-error-t2931/)

mdinu 9Feb2007 17:22

I dont know where is the error
 
Code:

#include <stdio.h>
#include <io.h>
//define XSIZE=100;
  int m,n;
  char *x,*y;
void preKmp(char *x, int m, int kmpNext[]) {
  int i, j;

  i = 0;
  j = kmpNext[0] = -1;
  while (i < m) {
      while (j > -1 && x[i] != x[j])
        j = kmpNext[j];
      i++;
      j++;
      if (x[i] == x[j])
        kmpNext[i] = kmpNext[j];
      else
        kmpNext[i] = j;
  }
}

void KMP(char *x, char *y) {
  int i, j, kmpNext[100], m,n;

  /* Preprocessing */
  preKmp(x, m, kmpNext);

  /* Searching */
  i = j = 0;
  while (j < n) {
      while (i > -1 && x[i] != y[j])
        i = kmpNext[i];
        printf("i=");scanf("%s/n",&i);
      i++;
      j++;
      if (i >= m) {
            printf("j-i");
        scanf("%d-%d",&j-&i);
        i = kmpNext[i];
      }
  }

int main()
{
  int m, n;
  char *x, *y;
 // printf("String: %s\n",&x);
  printf("string: ");scanf("%s",&x);
// printf("m: "); scanf("%d\n", m);
  printf("Pattern: "); scanf("%s", &y);
  //printf("n: "); scanf("%d\n", n);
  printf("KMP=");
  KMP( x, y);

}


#include <stdio.h>
#include <io.h>
//define XSIZE=100;
  int m, n;
  char *x, *y;
void preKmp(char *x, int m, int kmpNext[]) {
  int i, j;

  i = 0;
  j = kmpNext[0] = -1;
  while (i < m) {
      while (j > -1 && x[i] != x[j])
        j = kmpNext[j];
      i++;
      j++;
      if (x[i] == x[j])
        kmpNext[i] = kmpNext[j];
      else
        kmpNext[i] = j;
  }
}

void KMP(char *x, char *y) {
  int i, j, kmpNext[100], m,n;

  /* Preprocessing */
  preKmp(x, m, kmpNext);

  /* Searching */
  i = j = 0;
  while (j < n) {
      while (i > -1 && x[i] != y[j])
        i = kmpNext[i];
        printf("i=");scanf("%s/n",&i);
      i++;
      j++;
      if (i >= m) {
            printf("j-i");
        scanf("%d-%d",&j-&i);
        i = kmpNext[i];
      }
  }
}

int main()
{
  int m, n;
  char *x, *y;
 // printf("String: %s\n",&x);
  printf("string: ");scanf("%s",&x);
// printf("m: "); scanf("%d\n", m);
  printf("Pattern: "); scanf("%s", &y);
  //printf("n: "); scanf("%d\n", n);
  printf("KMP=");
  KMP( x, y);

}

i use lcc but i need help I do not find the mistake pls
Thanks in advance

shabbir 9Feb2007 17:38

Re: I dont know where is the error
 
You dont have the closing bracket for KMP


All times are GMT +5.5. The time now is 14:57.