Pagini recente » Cod sursa (job #2278734) | Cod sursa (job #1794761) | Cod sursa (job #2219409) | Cod sursa (job #2251242) | 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;
}