Advertisement
Josif_tepe

Untitled

May 31st, 2021
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int rekurzija(int *niza, int i, int n) {
  5.     if(i == n - 1) {
  6.         return niza[i];
  7.     }
  8.     if(rekurzija(niza, i + 1, n) < niza[i]) {
  9.         return niza[i];
  10.     }
  11.     return rekurzija(niza, i + 1, n);
  12. }
  13. int main() {
  14.     int n;
  15.     scanf("%d", &n);
  16.     int niza[n];
  17.     for(int i = 0; i < n; i++) {
  18.         scanf("%d", &niza[i]);
  19.     }
  20.     printf("%d\n", rekurzija(niza, 0, n));
  21.     return 0;
  22. }
  23.  
  24. // 7 3 7 15 1 292 1 1
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement