3 int naive3( int textrow
, int textcolumn
, int patternrow
, int patterncolumn
)
7 for(i
= textcolumn
; i
< patterncolumn
; i
++) {
11 for(j
= 0; j
< m
; j
++) {
13 if( pattern
[patternrow
][j
] == text
[textrow
][k
])
27 /* No match found on this row */
35 /* x and y can be -1 */
38 unsigned int i
, row
, matches
= 0;
41 for ( row
= 0; row
< n
- m
+ 1; row
++ ) {
45 /* Iterate through results on the same row */
48 x
= naive3( row
, x
, 0, n
- m
);
52 /* If a row is found, check the m - 1 rows underneath it for matches */
55 for ( i
= 1; i
< m
; i
++) {
56 /* Optimization: instead of checking against n chars on
57 subsequent rows, just check against the next m chars after x */
58 y
= naive3( row
+ i
, x
, i
, x
+ m
);
65 /* If we reached to the final line above x without breaking, we have a match */
69 /* After each attempt,increase the counter + 1 */
74 printf("Bird2: %i\n",matches
);