fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. cin>>n;
  8. int mn = 9, mx = 0, d;
  9. while(n > 0) {
  10. d=n % 10;
  11. mn=min(mn,d);
  12. mx=max(mx,d);
  13. n/=10;
  14. }
  15. cout<< mn<< " "<<mx<<endl;
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 5304KB
stdin
567
stdout
5 7