Pagini recente » Cod sursa (job #1225553) | Cod sursa (job #2616555) | Cod sursa (job #987081) | Cod sursa (job #2548034) | Cod sursa (job #1442207)
#include <cstdlib>
#include <cstdio>
using namespace std;
struct point{double x,y;};
struct drept{point st,dr;};
drept d1,d2,d3;
drept interior(drept d1,drept d2)
{drept d3;
if(d1.st.x>d2.st.x)
d3.st.x=d1.st.x;
else d3.st.x=d2.st.x;
if(d1.st.y>d2.st.y)
d3.st.y=d1.st.y;
else d3.st.y=d2.st.y;
if(d1.dr.x<d2.dr.x)
d3.dr.x=d1.dr.x;
else d3.dr.x=d2.dr.x;
if(d1.dr.y<d2.dr.y)
d3.dr.y=d1.dr.y;
else d3.dr.y=d2.dr.y;
if (d3.st.x>d3.dr.x || d3.st.y>d3.dr.y)
{
d3.st.x=0;
d3.dr.x=0;
d3.st.y=0;
d3.dr.y=0;
}
return d3;
}
double arie_drept(drept d)
{
return ((d.dr.x-d.st.x)*(d.dr.y-d.st.y));
}
double perimetru_drept(drept d)
{
return 2*(d.dr.x-d.st.x+d.dr.y-d.st.y);
}
int main()
{
drept a,b,c,d;
freopen("reuniune.in","r",stdin);
freopen("reuniune.out", "w", stdout);
scanf("%lf%lf%lf%lf",&d1.st.x,&d1.st.y,&d1.dr.x,&d1.dr.y);
scanf("%lf%lf%lf%lf",&d2.st.x,&d1.st.y,&d2.dr.x,&d2.dr.y);
scanf("%lf%lf%lf%lf",&d3.st.x,&d3.st.y,&d3.dr.x,&d3.dr.y);
a=interior(d1,d2);
b=interior(d1,d3);
c=interior(d2,d3);
d=interior(a,d3);
printf("%.0f ",arie_drept(d1)+arie_drept(d2)+arie_drept(d3)-arie_drept(a)-arie_drept(b)-arie_drept(c)+arie_drept(d));
printf("%.0f",perimetru_drept(d1)+perimetru_drept(d2)+perimetru_drept(d3)-perimetru_drept(a)-perimetru_drept(b)-perimetru_drept(c)+perimetru_drept(d));
}