Advertisement
Josif_tepe

Untitled

Jan 16th, 2024
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4.  
  5. void funkcija(char * s1, char * s2) {
  6.     int brojac = 0;
  7.     for(int i = 0; i < strlen(s1); i++) {
  8.         if(s1[i] == s2[0]) {
  9.             int ok = 1;
  10.             for(int j = 0; j < strlen(s2); j++) {
  11.                 if(i + j >= strlen(s1)) {
  12.                     ok = 0;
  13.                     break;
  14.                 }
  15.                 if(s1[i + j] != s2[j]) {
  16.                     ok = 0;
  17.                     break;
  18.                 }
  19.             }
  20.             if(ok == 1) {
  21.                 brojac++;
  22.             }
  23.         }
  24.     }
  25.     printf("Podnizata se pojavuva %d\n", brojac);
  26. }
  27. int main(int argc, const char * argv[]) {
  28.     char s1[1000];
  29.     char s2[1000];
  30.     fgets(s1, 500, stdin);
  31.     scanf("%s", s2);
  32.    
  33.     funkcija(s1, s2);
  34.     return 0;
  35. }
  36.  
  37.  
  38. /*
  39. */
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement