Pagini recente » Cod sursa (job #764447) | Cod sursa (job #49918) | Cod sursa (job #1526397) | Cod sursa (job #1771067) | Cod sursa (job #2176437)
#include <iostream>
#include <fstream>
#define nmax
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct Punct{
long double x, y;
};
inline long double determinant(Punct firstPoint, Punct secondPoint)
{
return firstPoint.x*secondPoint.y-secondPoint.x*firstPoint.y;
}
int main()
{
int numberPoints;
long double aria=0;
Punct firstPoint,secondPoint,auxfirstPoint;
fin>>numberPoints>>firstPoint.x>>firstPoint.y;
auxfirstPoint=firstPoint;
for(int i= 2; i <= numberPoints; ++i)
{
fin>>secondPoint.x>>secondPoint.y;
aria+=determinant(firstPoint,secondPoint);
firstPoint=secondPoint;
}
fin >> secondPoint.x >> secondPoint.y;
aria+=determinant(firstPoint,auxfirstPoint);
fout<< fixed << setprecision(6) << aria/2;
return 0;
}