fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. int n, a, b, c, minx, maxx, x1, x2, x3, x4, x5, x6;
  6. cin >> n;
  7. a = n / 100;
  8. b = (n / 10) % 10;
  9. c = n % 10;
  10. x1 = 100*a + 10*b + c;
  11. x2 = 100*a + 10*c + b;
  12. x3 = 100*b + 10*a + c;
  13. x4 = 100*b + 10*c + a;
  14. x5 = 100*c + 10*b + a;
  15. x6 = 100*c + 10*a + b;
  16. minx = 1000;
  17. maxx = 0;
  18. if(x1 >= 100 and x1 < minx){
  19. minx = x1;
  20. }
  21. else if(x2 >= 100 and x2 < minx){
  22. minx = x2;
  23. }
  24. else if(x3 >= 100 and x3 < minx){
  25. minx = x3;
  26. }
  27. else if(x4 >= 100 and x4 < minx){
  28. minx = x4;
  29. }
  30. else if(x5 >= 100 and x5 < minx){
  31. minx = x5;
  32. }
  33. else if(x6 >= 100 and x6 < minx){
  34. minx = x6;
  35. }
  36.  
  37. if(x1 >= 100 and x1>maxx){
  38. maxx = x1;
  39. }
  40. else if(x2 >= 100 and x2>maxx){
  41. maxx = x2;
  42. }
  43. else if (x3 >= 100 and x3>maxx){
  44. maxx = x3;
  45. }
  46. else if (x4 >= 100 and x4>maxx){
  47. maxx = x4;
  48. }
  49. else if(x5 >= 100 and x5>maxx){
  50. maxx = x5;
  51. }
  52. else if (x6 >= 100 and x6>maxx){
  53. maxx = x6;
  54. }
  55. cout << minx + maxx;
  56. }
Success #stdin #stdout 0.01s 5512KB
stdin
232
stdout
464