Cod sursa(job #2653106)
| Utilizator | Data | 26 septembrie 2020 21:11:29 | |
|---|---|---|---|
| Problema | Aria | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#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;
}