Pagini recente » Cod sursa (job #558866) | Cod sursa (job #3213385) | Cod sursa (job #1009632) | Cod sursa (job #647112) | Cod sursa (job #2176435)
#include <iostream>
#include <fstream>
#define nmax
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct Punct{
int x, y;
};
int determinant(Punct firstPoint, Punct secondPoint)
{
return firstPoint.x*secondPoint.y-secondPoint.x*firstPoint.y;
}
int main()
{
int numberPoints;
int 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;
}