Pagini recente » Borderou de evaluare (job #2527356) | Borderou de evaluare (job #2071796) | Borderou de evaluare (job #152056) | Borderou de evaluare (job #2912158) | Cod sursa (job #1800124)
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iomanip>
using namespace std;
long double getArea (long double lx, long double ly, long double x, long double y) {
//ly = translate (ly);
//y = translate (y);
long double X = x - lx;
return X * (ly + y);
}
int main () {
int n;
long double x, y, lx, ly, x0, y0, a = 0, k;
ifstream cin ("aria.in");
ofstream cout ("aria.out");
cin >> n;
if (n == 1) {
cout << fixed << setprecision (6) << a << '\n';
return 0;
}
cin >> lx >> ly;
x0 = lx; y0 = ly;
for (int i = 1; i < n; i++) {
cin >> x >> y;
a += getArea (lx, ly, x, y);
lx = x; ly = y;
}
a += getArea (lx, ly, x0, y0);
a = a / (long double) 2;
cout << fixed << setprecision(6) << abs(a) << '\n';
return 0;
}