Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- int occurrences( char *a, char *b )
- {
- int i, j, szamlalo=0, x=0;
- char *masolat;
- char *hol;
- szamlalo=0;
- for (i=0; a[i]; i++){
- if (a[i]==b[0]){
- for (j=0; b[j]; j++){
- if (a[i+j]==b[j])
- x++;
- }
- if (x==strlen(b))
- szamlalo++;
- x=0;
- }
- }
- return szamlalo;
- }
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- char s1[ 1000 ], s2[ 1000 ];
- int occurrences( char *, char * );
- while ( scanf( "%s%s", s1, s2 ) != EOF )
- printf( "%d\n", occurrences( s1, s2 ) );
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement