josiftepe

Untitled

Dec 25th, 2020
61
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. #include <stdlib.h>
  3.  
  4. int max(int a, int b){
  5.     if(a>b)
  6.         return a;
  7.     else
  8.         return b;
  9. }
  10. int rekurzija(int broj){
  11.     if(broj==0)
  12.         return 0;
  13.     else{
  14.         int digit=broj%10;
  15.         return max(rekurzija(broj/10), digit); // maksimum od cifrata i rekurzijata
  16.     }
  17. }
  18.  
  19. int main()
  20. {
  21.     int broj;
  22.     while(scanf("%d", &broj)){
  23.         printf("%d\n", rekurzija(broj));
  24.     }
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment