fork(2) download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. int main()
  5. {
  6. int x[4],y[4];
  7. int pole = 0;
  8. cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3];
  9. pole = (x[1] - x[0])*(y[1] - y[0]) + (x[3] - x[2])*(y[3] - y[2]);
  10. if (x[1]<x[2]||x[0]>x[3]||y[0]>y[3]||y[2]>y[1])
  11. cout<<pole;
  12. else
  13. {
  14. sort ( x , x + 4 );
  15. sort ( y , y + 4 );
  16. pole = pole - (x[2]-x[1])*(y[2]-y[1]);
  17. cout<<pole;
  18. }
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 3472KB
stdin
1 0 0 10 10 2 2 8 8
stdout
-58