Ilitid

Max Digit

Dec 18th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.17 KB | None | 0 0
  1. int maxDigit(int x){
  2.     if (x > 0) {
  3.         return max(x % 10, maxDigit(x / 10));
  4.     }
  5. }
  6.  
  7. int minDigit(int x){
  8.     return (x < 10) ? x : min(x%10, minDigit(x/10));
  9. }
Advertisement
Add Comment
Please, Sign In to add comment