Cod sursa(job #3258728)
| Utilizator | Data | 23 noiembrie 2024 14:41:39 | |
|---|---|---|---|
| Problema | Aria | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 kb |
#include <iostream>
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
int main() {
int n;
long double aria=0.0,x1,x2,y1,y2;
fin >> n;
fin >> x1 >> y1;
int firstX = x1, firstY = y1;
for (int i = 1; i < n; i++)
{
fin >> x2 >> y2;
aria += x1 * y2 - y1 * x2;
x1 = x2;
y1 = y2;
}
aria += x1 * firstY - y1 * firstX;
fout << fixed << setprecision(5) << abs(aria/2.0) << endl;
return 0;
}
