fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a, b, c, d;
  6. cin >> a >> b >> c >> d;
  7. if (a > c) {
  8. swap(a,c);
  9. swap(b,d);
  10. }
  11. cout << ((c < b)? max(b , d) - a : (b - a) + (d - c));
  12. return 0;
  13. }
Success #stdin #stdout 0s 5488KB
stdin
7 10
4 8
stdout
6