fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. int max_number(int value) {
  5. if (!value) return 0;
  6. return std::max(value % 10, max_number(value / 10));
  7. }
  8.  
  9. int main() {
  10. int value = 78421;
  11. std::cout << "max number is: " << max_number(value);
  12. }
  13.  
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
max number is: 8