Pagini recente » Cod sursa (job #1915940) | Cod sursa (job #174954) | r3capitusulare | Cod sursa (job #2669331) | Cod sursa (job #2829233)
#include <fstream>
#include <cmath>
#include <iomanip>
int main() {
std::ifstream fin("aria.in");
std::ofstream fout("aria.out");
int nrn;
double posx, posy, antx, anty, fstx, fsty;
double ans = 0;
fin >> nrn;
fin >> antx >> anty;
fstx = antx;
fsty = anty;
for (int index = 1; index < nrn; index++) {
fin >> posx >> posy;
ans += posx * anty - posy * antx;
antx = posx;
anty = posy;
}
ans += fstx * anty - fsty * antx;
fout << std::fixed << std::setprecision(5) << std::abs(ans) / 2;
}