Pagini recente » Cod sursa (job #1268786) | Cod sursa (job #1054647) | Cod sursa (job #1106327) | Cod sursa (job #2569027) | Cod sursa (job #2156733)
#include<fstream>
#include<iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
typedef long double ld;
struct Point{
ld x, y;
};
inline ld determinant(Point firstPoint, Point secondPoint){
return firstPoint.x * secondPoint.y - secondPoint.x * firstPoint.y;
}
int main(){
int pointsCnt;
ld area = 0;
Point firstPoint, secondPoint, auxFirstPoint;
fin >> pointsCnt >> firstPoint.x >> firstPoint.y;
auxFirstPoint = firstPoint;
int idx;
for(idx = 2; idx <= pointsCnt; ++idx){
fin >> secondPoint.x >> secondPoint.y;
area += determinant(firstPoint, secondPoint);
firstPoint = secondPoint;
}
fin >> secondPoint.x >> secondPoint.y;
area += determinant(firstPoint, auxFirstPoint);
fout << fixed << setprecision(6) << area / 2;
}