fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a, b, c;
  6. int x;
  7. cin >> a >> b >> c;
  8. if (a > b && b > c && b < a) {
  9. x = a - c - 2;
  10. cout << x;
  11. } else if (a > b && b < c && c < a) {
  12. x = a - b - 2;
  13. cout << x;
  14. } else if (b > a && a > c && a < b) {
  15. x = b - c - 2;
  16. cout << x;
  17. } else if (b > a && a < c && c < b) {
  18. x = b - a - 2;
  19. cout << x;
  20. } else if (c > a && a > b && a < c) {
  21. x = c - b - 2;
  22. cout << x;
  23. } else {
  24. x = c - a - 2;
  25. cout << x;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5304KB
stdin
3 5 10
stdout
5