Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int f(char str[80], char sm[10]) {
- int c = 0;
- for(int i = 0; i < strlen(str); i++) {
- int j;
- for(j = 0; sm[j] == str[i + j]; j++) {}
- if(j == strlen(sm)) {
- c++;
- }
- }
- return c;
- }
- int main() {
- int N = 80, M = 10;
- char s1[N], s2[N], sm[M];
- gets(s1);
- gets(s2);
- gets(sm);
- int s1_c = f(s1, sm), s2_c = f(s2, sm);
- printf("%s\n%s\n", s1, s2);
- printf("dans s1 - %d fois", s1_c);
- printf("dans s2 - %d fois", s2_c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement