Pagini recente » Cod sursa (job #3168258) | Cod sursa (job #1949219) | Cod sursa (job #717688) | Cod sursa (job #2760791) | Cod sursa (job #829290)
Cod sursa(job #829290)
#include<fstream>
#define inf 10000000000
using namespace std;
ofstream g("reuniune.out");
int i,j,l1,l2,arie,p;
struct drept
{
int ix,iy,ox,oy;
};
drept a[4],c;
int lungime(int a,int b)
{
return max(a,b)-min(a,b);
}
void intersectie(drept a,drept b)
{
++j;
c.ix=max(a.ix,b.ix);
c.iy=max(a.iy,b.iy);
c.ox=min(a.ox,b.ox);
c.oy=min(a.oy,b.oy);
if(c.ix<a.ix||c.ix<b.ix||c.ox>a.ox||c.ox>b.ox||c.iy<a.iy||c.iy<b.iy||c.oy>a.oy||c.oy>b.oy)
{
c.ix=c.iy=c.ox=c.oy=inf;
}
l1=lungime(c.ix,c.ox);
l2=lungime(c.iy,c.oy);
//g<<c[j].ix<<" "<<c[j].iy<<" "<<c[j].ox<<" "<<c[j].oy<<" "<<l1<<" "<<l2<<"\n";
if(j!=4)
{
arie-=(l1*l2);
p-=2*(l1+l2);
}
else
{
arie+=(l1*l2);
p+=2*(l1+l2);
}
}
int main()
{
ifstream f("reuniune.in");
for(i=1;i<=3;++i)
{
f>>a[i].ix>>a[i].iy>>a[i].ox>>a[i].oy;
l1=lungime(a[i].ox,a[i].ix);
l2=lungime(a[i].iy,a[i].oy);
p+=2*(l1+l2);
arie+=l1*l2;
}
intersectie(a[1],a[2]);
intersectie(a[1],a[3]);
intersectie(a[2],a[3]);
intersectie(a[1],c);
g<<arie<<" "<<p<<"\n";
}