Cod sursa(job #1142357)
Utilizator | Data | 13 martie 2014 18:56:43 | |
---|---|---|---|
Problema | Aria | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.52 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main(int argc, char *argv[])
{
ifstream f("aria.in");
ofstream g("aria.out");
int n;
f >> n;
double area = 0.0;
double x, y, prev_x, prev_y, first_x, first_y;
f >> prev_x >> prev_y;
first_x = prev_x;
first_y = prev_y;
for(int i = 0; i < n - 1; i++) {
f >> x >> y;
area += x * prev_y - prev_x * y;
prev_x = x;
prev_y = y;
}
area += first_x * prev_y - first_y * prev_x;
g << abs(0.5 * area);
return 0;
}