Cod sursa(job #1517516)
| Utilizator | Data | 4 noiembrie 2015 15:04:44 | |
|---|---|---|---|
| Problema | Aria | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <fstream>
#include <vector>
#include <cmath>
using namespace std;
ifstream is("aria.in");
ofstream os("aria.out");
struct Punct{
double x, y;
};
int n;
double s;
vector<Punct> v;
int main()
{
is >> n;
v.resize(n + 2);
for ( int i = 1; i <= n; ++i )
is >> v[i].x >> v[i].y;
v[n + 1] = v[1];
for ( int i = 1; i <= n; ++i )
s += v[i].x * v[i + 1].y - v[i].y * v[i + 1].x;
if ( s < 0 )
s *= -1;
os << s / 2.000000;
is.close();
os.close();
return 0;
}
