Advertisement
Guest User

rec

a guest
Jan 20th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int Max(int i, int n, int *a)
  4. {
  5. int m;
  6. if(i==n-1) return a[i]; // the last value is the maximum for this step
  7. m = Max(i+1, n, a);
  8. return ((a[i] > m)? a[i] : m);
  9. }
  10.  
  11. int main()
  12. {
  13. int n, i, m, a[100];
  14. scanf("%d", &n);
  15. for(i=0; i<n; i++)
  16. scanf("%d", &a[i]);
  17. m = Max(0, n, a);
  18. printf("%d\n", m);
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement