Pagini recente » Cod sursa (job #120104) | Cod sursa (job #2424334) | Cod sursa (job #2385172) | Cod sursa (job #2358402) | Cod sursa (job #2653105)
#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(5) << A;
return 0;
}