Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- void funkcija(char * tekst, char * zbor) {
- int brojac = 0;
- for(int i = 0; i < strlen(tekst); i++) {
- if(tekst[i] == zbor[0]) {
- int ok = 1;
- for(int j = 0; j < strlen(zbor); j++) {
- if(tekst[i + j] != zbor[j]) {
- ok = -1;
- break;
- }
- }
- if(ok == 1) {
- brojac++;
- }
- }
- }
- printf("%d\n", brojac);
- }
- int main(int argc, const char * argv[]) {
- char tekst[1000], zbor[1000];
- fgets(tekst, 500, stdin);
- scanf("%s", zbor);
- funkcija(tekst, zbor);
- }
- /*
- 14 12 -6 20 15 -1 10 6 -7 -20
- 14, 12, -6, -7, -8, -9, -10, -20
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement