fork download
  1. #include <iostream>
  2.  
  3. int main() {
  4.  
  5. int a{}, b{}, c{}, d{};
  6. int input;
  7.  
  8. while ((std::cin >> input))
  9. switch(input%3)
  10. {
  11. case 0:
  12. if (input > a) {b = a; a = input;}
  13. else if (input > b) b = input;
  14. break;
  15. case 1:
  16. if (input > c) c = input;
  17. break;
  18. case 2:
  19. if (input > d) d = input;
  20. break;
  21. }
  22.  
  23. if (a+b > c+d) std::cout << a << '+' << b << '=' << a + b;
  24. else std::cout << c << '+' << d << '=' << c + d;
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3144KB
stdin
15 27 31 42 53 66 77 82 95 101 13
stdout
82+101=183