Pagini recente » Cod sursa (job #2821596) | Cod sursa (job #1499467) | Cod sursa (job #1420923) | Cod sursa (job #2478101) | Cod sursa (job #2653106)
#include <fstream>
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(int argc, char const *argv[])
{
ifstream fin("aria.in");
ofstream fout("aria.out");
int N;
fin >> N;
float x0, y0, x1, y1;
fin >> x0 >> y0;
x1 = x0; y1 = y0;
float A = 0;
for (int i = 1; i < N; i++)
{
float x2, y2;
fin >> x2 >> y2;
A += (x1 * y2 - x2 * y1);
x1 = x2; y1 = y2;
}
A += (x1 * y0 - x0 * y1);
A /= 2;
A = abs(A);
fout << fixed << setprecision(6) << A;
return 0;
}