Skip to content

Instantly share code, notes, and snippets.

@Eugeny
Created March 18, 2012 16:26
Show Gist options
  • Save Eugeny/2076819 to your computer and use it in GitHub Desktop.
Save Eugeny/2076819 to your computer and use it in GitHub Desktop.
var
x1, x2, x3, x4, y1, y2, y3, y4, t, s : integer;
begin
x1 := 1; x2 := 3; y1 := 1; y2 := 3;
x3 := 2; x4 := 4;
y3 := 2; y4 := 4;
s := 0;
if x1 > x2 then begin
t := x1;
x1 := x2;
x2 := t;
end;
if x3 > x4 then begin
t := x3;
x3 := x4;
x4 := t;
end;
if y1 > y2 then begin
t := y1;
y1 := y2;
y2 := t;
end;
if y3 > y4 then begin
t := y3;
y3 := y4;
y4 := t;
end;
if (x3 > x1) and (x3 < x2) and (y3 > y1) and (y3 < y2) then begin
s := (x2-x3) * (y2-y3);
end;
if (x4 > x1) and (x4 < x2) and (y4 > y1) and (y4 < y2) then begin
s := (x4-x1) * (y4-y1);
end;
if (x3 > x1) and (x3 < x2) and (y4 > y1) and (y4 < y2) then begin
s := (x2-x3) * (y4-y1);
end;
if (x4 > x1) and (x4 < x2) and (y3 > y1) and (y3 < y2) then begin
s := (x4-x1) * (y2-y3);
end;
writeln(s);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment