Pagini recente » Cod sursa (job #1630828) | Cod sursa (job #2917238) | Cod sursa (job #1527685) | Cod sursa (job #620535) | Cod sursa (job #2535759)
#include <iostream>
#include <vector>
#include <fstream>
#include <iomanip>
using namespace std;
struct punct{
long double x, y;
punct(long double x = 0, long double y = 0){
this->x = x;
this->y = y;
}
};
int n;
vector<punct> puncte;
ifstream f("aria.in");
ofstream g("aria.out");
long double determinant(punct a, punct b, punct c){
long double rez = (a.x - c.x) * (b.y - c.y) - (a.y - c.y) * (b.x - c.x);
// if(rez < 0)
// rez *= -1;
return rez;
}
int main() {
f>>n;
for (int i = 0; i < n; ++i) {
puncte.emplace_back();
f>>puncte[i].x>>puncte[i].y;
}
long double aria2 = 0;
for (int i = 1; i < n - 1; ++i) {
aria2 += determinant(puncte[0], puncte[i], puncte[i + 1]);
}
aria2 /= 2;
g<<setprecision(15)<<aria2;
return 0;
}