Cod sursa(job #3219264)
| Utilizator | Data | 30 martie 2024 16:24:07 | |
|---|---|---|---|
| Problema | Aria | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 kb |
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
ifstream in("aria.in");
ofstream out("aria.out");
int n, total;
int main()
{
in >> n;
float xi, yi, primx, primy;
float xc, yc;
in >> xi >> yi;
primx = xi, primy = yi;
for(int i = 1; i < n; i++){
in >> xc >> yc;
float s = (xi * yc - xc * yi) / 2;
total += s;
xi = xc, yi = yc;
}
float s = (xc * primy - primx * yc) / 2;
total += s;
out << fixed << setprecision(5) << abs(total);
return 0;
}
