Advertisement
Mixilino

dasd

Apr 17th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. void podniz(int niz[], int n, int niz2[], int * brEl2) {
  3.     int trenutni = 0;
  4.     int maxBroj = trenutni;
  5.     int donjaGranica=0;
  6.     int gornjaGranica=0;
  7.     for (int i = 0; i < n; i++)
  8.     {
  9.         if (niz[i] % 2 == 1) {
  10.             trenutni++;
  11.         }
  12.         else {
  13.             trenutni = 0;
  14.         }
  15.         if (trenutni > maxBroj) {
  16.             maxBroj = trenutni;     // ovo je broj clanova u tom nizu
  17.             gornjaGranica = i;
  18.             donjaGranica = gornjaGranica - maxBroj + 1;
  19.         }
  20.     }
  21.     for (int i = 0; i < maxBroj; i++)
  22.     {
  23.         niz2[i] = niz[donjaGranica + i];
  24.     }
  25.     *brEl2 = maxBroj;
  26. }
  27.  
  28. int main(void) {
  29.     int niz[11] = { 1,2,2,3,3,5,4,3,78,6,5 };
  30.     int brEl = 11;
  31.     int niz2[11];
  32.     int brEl2;
  33.     podniz(niz, brEl, niz2, &brEl2);
  34.     for (int i = 0; i < brEl2; i++)
  35.     {
  36.         printf("%d\t", niz2[i]);
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement