void ch(char *a,char *b,int i,int j,char *p)
{
if(j==strlen(b)-1)sum++;
while(j<strlen(b)-1)
{
int n=strlen(b);
p+=i;j++;
//printf("%s %d\n",p,j);
if(*(p+1)==b[j]){i=1;ch(a,b,i,j,p);}
if(*(p-1)==b[j]){i=-1;ch(a,b,i,j,p);}
if(*(p+n)==b[j]){i=n;ch(a,b,i,j,p);}
if(*(p-n)==b[j]){i=-n;ch(a,b,i,j,p);}
if(*(p+n+1)==b[j]){i=n+1;ch(a,b,i,j,p);}
if(*(p+n-1)==b[j]){i=n-1;ch(a,b,i,j,p);}
if(*(p-n+1)==b[j]){i=1-n;ch(a,b,i,j,p);}
if(*(p-n-1)==b[j]){i=-n-1;ch(a,b,i,j,p);}
//else return 0;
}
//return sum;
}
there are 2 arrays a,b and elements of b are compared with the that of a at logical positions. The problem is it gives double of the expected value. Seems like a small bug but can't figure it out.


Sign In
Create Account


Back to top









