Advertisement
rana1704

BruteForce

Nov 23rd, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include<stdio.h>
  2. void main(){
  3.     int i=0, j, textLength, patternLength, match = 0;
  4.     char text[100] = "3412894334012348621032803234567";
  5.     char pattern[100]="234";
  6.     //gets(text);
  7.     //gets(pattern);
  8.  
  9.     textLength = strlen(text);
  10.     patternLength = strlen(pattern);
  11.  
  12.  
  13.     for( i = 0; i < textLength - patternLength + 1; i++){
  14.         for(j=0;j<patternLength;j++){
  15.             if( text[i+j] != pattern[j] ){
  16.                 break;
  17.             }
  18.         }
  19.         if( patternLength == j ){
  20.             match++;
  21.         }
  22.     }
  23.     printf("Pattern Match %d times", match);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement