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