Skip to content

Commit

Permalink
Update naive_search.c
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme authored May 12, 2019
1 parent 25a225c commit d970259
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions searching/pattern_search/naive_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ void naive_search(char *str, char *pattern)
int len_str = strlen(str);
int len_pat = strlen(pattern);

for(int i = 0; i <= len_str - len_pat; i++)
for (int i = 0; i <= len_str - len_pat; i++)
{
int j;
for(j = 0; j < len_pat; j++)
for (j = 0; j < len_pat; j++)
{
if(str[i + j] != pattern[j])
if (str[i + j] != pattern[j])
break;
}
if (j == len_pat)
Expand All @@ -24,7 +24,7 @@ int main()
{
char str[] = "AABCAB12AFAABCABFFEGABCAB";
char pat1[] = "ABCAB";
char pat2[] = "FFF"; /* not found */
char pat2[] = "FFF"; /* not found */
char pat3[] = "CAB";

printf("String test: %s\n", str);
Expand Down

0 comments on commit d970259

Please sign in to comment.