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[]) {
- int n;
- scanf("%d", &n);
- int niza[n];
- for(int i = 0; i < n; i++) {
- scanf("%d", &niza[i]);
- }
- int h;
- scanf("%d", &h);
- if(h > n) {
- printf("Ne validno h\n");
- return 0;
- }
- for(int i = 0; i < n; i++) {
- if(i + h < n) {
- int ok = -1;
- for(int j = i; j < i + h; j++) {
- if(niza[j] == h) {
- ok = 1;
- break;
- }
- }
- if(ok == 1) {
- for(int j = i; j < i + h; j++) {
- printf("%d ", niza[j]);
- }
- printf("\n");
- }
- }
- }
- }
- /*
- 11
- 4 15 1 42 52 5 39 2 18 87 91
- 5
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement