Advertisement
OnyRoman

Untitled

Mar 16th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. long long a, b, maxa, maxb, mina, minb, mina0, minb0;
  7. cin >> a >> b;
  8. for (maxa = 0, mina = 10; a != 0; a/=10) {
  9. if (a%10 > maxa)
  10. maxa = a % 10;
  11. if (a%10 < mina && a % 10 != 0)
  12. mina = a % 10;
  13. if (a % 10 == 0)
  14. mina0 = 0;
  15. }
  16. for (maxb = 0, minb = 10; b != 0; b/=10) {
  17. if (b%10 > maxb)
  18. maxb = b % 10;
  19. if (b%10 < minb && b %10 != 0)
  20. minb = b % 10;
  21. if (b % 10 == 0)
  22. minb0 = 0;
  23. }
  24.  
  25. if (mina0 == 0) {
  26. if (minb <= mina)
  27. cout << minb * 10 << " ";
  28. }
  29. else if (minb0 == 0) {
  30. if (mina <= minb)
  31. cout << mina * 10 << " ";
  32. }
  33. else if (mina < minb)
  34. cout << mina * 10 + minb << " ";
  35. else
  36. cout << minb * 10 + mina << " ";
  37.  
  38. if (maxa > maxb)
  39. cout << maxa * 10 + maxb;
  40. else
  41. cout << maxb * 10 + maxa;
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement