fork download
  1.  
  2. // Online C++ Compiler - Build, Compile and Run your C++ programs online in your favorite browser
  3.  
  4. #include<iostream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int x,y,z;
  11. cin >> x >> y >> z;
  12.  
  13. int d1 = (x-y)-(x-z);
  14. if(d1 < 0) d1 = -1 * d1;
  15.  
  16. int d2 = (y-x)-(y-z);
  17. if(d2 < 0) d2 = -1 * d2;
  18.  
  19. int d3 = (z-x)-(z-y);
  20. if(d3 < 0) d3 = -1 * d3;
  21.  
  22. if(d1 <= d2 and d1 <= d3) cout << d1*2;
  23. else if(d2 <= d1 and d2 <= d3) cout << d2*2;
  24. else cout << d3*2;
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
21708