fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n;
  7. cin >> n;
  8.  
  9. if(n == 0)
  10. return 0;
  11.  
  12. int ans = -1;//INT_MIN;
  13.  
  14. while(n > 0)
  15. {
  16. int x = n%10;
  17. n = n/10;
  18.  
  19. ans = (ans > x)? ans : x;
  20. }
  21. cout << ans << endl;
  22. return 0;//ans;
  23. }
Success #stdin #stdout 0s 4548KB
stdin
5
stdout
5