Pagini recente » Cod sursa (job #1407219) | Cod sursa (job #1422220) | Cod sursa (job #3127447) | Cod sursa (job #3194641) | Cod sursa (job #2829194)
#include <fstream>
using namespace std;
ifstream in("reuniune.in");
ofstream out("reuniune.out");
struct drept
{
long long xjos, yjos, xsus, ysus;
};
long long area(drept x)
{
return (x.xsus - x.xjos) * (x.ysus - x.yjos );
}
long long perimeter(drept x)
{
return (2 * ( (x.xsus - x.xjos) + (x.ysus - x.yjos ) ) );
}
drept intersectie(drept a, drept b)
{
drept ans;
ans.xjos = max(a.xjos, b.xjos);
ans.yjos = max(a.yjos, b.yjos);
ans.xsus = min(a.xsus, b.xsus);
ans.ysus = min(a.ysus, b.ysus);
if(ans.xjos > ans.xsus || ans. yjos > ans.ysus)
{
ans.xjos = 0;
ans.yjos = 0;
ans.xsus = 0;
ans.ysus = 0;
}
return ans;
}
drept a, b, c;
long long perimt, areat;
int main()
{
in>>a.xjos>>a.yjos>>a.xsus>>a.ysus>>b.xjos>>b.yjos>>b.xsus>>b.ysus>>c.xjos>>c.yjos>>c.xsus>>c.ysus;
areat = area(a) + area(b) + area(c) - area(intersectie(a,b)) - area(intersectie(c,b)) - area(intersectie(a,c)) + area(intersectie(a,intersectie(b, c)));
perimt = perimeter(a) + perimeter(b) + perimeter(c) - perimeter(intersectie(a,b)) - perimeter(intersectie(a,c)) - perimeter(intersectie(b,c)) + perimeter(intersectie(a,intersectie(b, c)));
out<<areat<<" "<<perimt;
return 0;
}