Mr…..
…B….
…ee…
For every element, check all its neighbour element to get the match
flag=0; i=0; j=1; for (k=0;k<n;k++) { for(l=0;l<n;l++) { if(m[k][l] == str) { x=k; y=l; break; } } } while(str[j] != '\0') { if(m[x][y+1] == str[j]) { y = y+1; } else if(m[x][y-1] == str[j]) { y = y-1; } else if(m[x+1][y] == str[j]) { x = x+1; } else if(m[x-1][y] == str[j]) { x=x-1; } else if(m[x-1][y-1] == str[j]) { x=x-1; y=y-1; } else if(m[x-1][y+1] == str[j]) { x = x-1; y=y+1; } else if(m[x+1][y-1] == str[j]) { x=x+1; y=y-1; } else if(m[x+1][y+1] == str[j]) { x=x+1; y=y+1; } else { flag =1; break; } i++; j++; } if(flag == 0) { printf(”String is Contiguous !!\n”); } else { printf(”String is not Contiguous …\n”); } |

Leave a Reply
You must be logged in to post a comment.