Advertisement
zsoltizbekk

szamolo

Apr 14th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <string.h>
  2. int occurrences( char *a, char *b )
  3. {
  4.     int i, j, szamlalo=0, x=0;
  5.     char *masolat;
  6.     char *hol;
  7.     szamlalo=0;
  8.     for (i=0; a[i]; i++){
  9.         if (a[i]==b[0]){
  10.             for (j=0; b[j]; j++){
  11.                 if (a[i+j]==b[j])
  12.                     x++;
  13.             }
  14.             if (x==strlen(b))
  15.                     szamlalo++;
  16.                 x=0;
  17.         }
  18.     }
  19.     return szamlalo;
  20. }
  21.  
  22.  
  23.  
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. int main()
  28. {
  29.   char s1[ 1000 ], s2[ 1000 ];
  30.   int occurrences( char *, char * );
  31.   while ( scanf( "%s%s", s1, s2 ) != EOF )
  32.     printf( "%d\n", occurrences( s1, s2 ) );
  33.   return EXIT_SUCCESS;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement