Advertisement
Dizzy3113

Untitled

Nov 17th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void max_d(int n, int &m1, int &m2)
  6. {
  7. m1=0;
  8. m2=0;
  9. int x=n;
  10. while(n)
  11. {
  12. if(n%10>m1)
  13. m1=n%10;
  14. n=n/10;
  15. }
  16. while(x)
  17. {
  18. if(x%10<m1 && x%10>m2)
  19. m2=x%10;
  20. x=x/10;
  21. }
  22. }
  23. int main()
  24. {
  25.  
  26. int n=97332, m1, m2;
  27. max_d(n, m1, m2);
  28. cout<<m1<<" "<<m2;
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement