Cod sursa(job #1647038)
Utilizator | Radu Matei Lacraru lacraruradu | Data | 10 martie 2016 18:46:28 |
---|---|---|---|
Problema | Aria | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.58 kb |
#include <fstream>
#include <iomanip>
using namespace std;
ifstream in("aria.in");
ofstream out("aria.out");
int n;
double x, y, x1, y1;
int main()
{
in >> n;
in >> x >> y;
x1 = x;
y1 = y;
double xcurent, ycurent;
double arie = 0;
n--;
while(n--)
{
in >> xcurent >> ycurent;
arie += (double)(xcurent - x)*(ycurent + y);
x = xcurent;
y = ycurent;
}
arie += (double)(x1 - x)*(y1 + y);
if(arie < 0)
arie = -arie;
out << setprecision(15) << arie / 2;
return 0;
}