Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void podniz(int niz[], int n, int niz2[], int * brEl2) {
- int trenutni = 0;
- int maxBroj = trenutni;
- int donjaGranica=0;
- int gornjaGranica=0;
- for (int i = 0; i < n; i++)
- {
- if (niz[i] % 2 == 1) {
- trenutni++;
- }
- else {
- trenutni = 0;
- }
- if (trenutni > maxBroj) {
- maxBroj = trenutni; // ovo je broj clanova u tom nizu
- gornjaGranica = i;
- donjaGranica = gornjaGranica - maxBroj + 1;
- }
- }
- for (int i = 0; i < maxBroj; i++)
- {
- niz2[i] = niz[donjaGranica + i];
- }
- *brEl2 = maxBroj;
- }
- int main(void) {
- int niz[11] = { 1,2,2,3,3,5,4,3,78,6,5 };
- int brEl = 11;
- int niz2[11];
- int brEl2;
- podniz(niz, brEl, niz2, &brEl2);
- for (int i = 0; i < brEl2; i++)
- {
- printf("%d\t", niz2[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement