Advertisement
Josif_tepe

Untitled

Aug 24th, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. #include <math.h>
  5. int maksCifra(int broj) {
  6.     if(broj < 10) {
  7.         return broj;
  8.     }
  9.     int cifra = broj % 10;
  10.     int maks = maksCifra(broj / 10);
  11.     if(cifra > maks) {
  12.         return cifra;
  13.     }
  14.     else {
  15.         return maks;
  16.     }
  17. }
  18. int main() {
  19.  
  20.     printf("%d\n", maksCifra(897));
  21.    
  22.     return 0;
  23. }
  24. /*
  25. maksCifra(897) = maximum(7, 9) = 9
  26. maksCifra(89) = max(9, 8) = 9
  27.  maksCifra(8) = 8
  28. */
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement