Advertisement
Mixilino

podniz

Apr 17th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. int podniz(int niz[], int n) {
  3.     int trenutni = 0;
  4.     int max = trenutni;
  5.     for (int i = 0; i < n; i++)
  6.     {
  7.         if (niz[i] % 2 == 1) {
  8.             trenutni++;
  9.         }
  10.         else {
  11.             trenutni = 0;
  12.         }
  13.         if (trenutni > max) {
  14.             max = trenutni;
  15.         }
  16.     }
  17.     return max;
  18. }
  19.  
  20. int main(void) {
  21.     int niz[11] = { 1,2,2,3,3,5,4,3,78,6,5 };
  22.     int brEl = 11;
  23.     int brojNajduzegPodnizaNeparnih = podniz(niz, brEl);
  24.     printf("%d", brojNajduzegPodnizaNeparnih);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement