#include<fstream.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
struct punct{int x,y;};
int X,Y;
punct v[20];
int n;
int S;
int xs,ys,xd,yd;
void taiere(int x1,int y1,int x2,int y2)
//x1,y1; x2,y2-coordonatele coltului stg-jos,dr-sus;
{int g=0,poz;
for(int i=1;i<=n && !g;i++)//ma opresc cand dau
peste o perforatie in interiorul suprafetei
if(v[i].x>x1
&& v[i].x<x2 && v[i].y>y1 && v[i].y<y2)
{g=1;
poz=i;}
if (g==1)
{taiere(x1,v[poz].y,x2,y2); //deasupra
taiere(x1,y1,x2,v[poz].y);//dedesupt
taiere(x1,y1,v[poz].x,y2);//stanga
taiere(v[poz].x,y1,x2,y2);//dreapta
}
else if
((x2-x1)*(y2-y1)>S)
{xs=x1;
ys=y1;
xd=x2;
yd=y2;
S=(x2-x1)*(y2-y1);
}
}
void main()
{clrscr();
fstream f("placa.in",ios::in);
if(f)
cout<<"ok";
else
cout<<"eroare";
f>>n;
for(int i=1;i<=n;i++)
f>>v[i].x>>v[i].y;
f>>X>>Y;
taiere(0,0,X,Y);
cout<<endl<<"Cea mai mare suprafata
neperforata are coordonatele
("<<xs<<","<<ys<<");("<<xd<<","<<yd<<")"<<endl;
cout<<"Are suprafata "<<S;
getch();
}