Cod sursa(job #1576414)

Utilizator GuzgleteBumbu Alexandru Guzglete Data 22 ianuarie 2016 13:59:48
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.58 kb
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    int n,i;
    double x0,y0,x1,y1,x2,y2;
    long double S=0;
    FILE *f=fopen("aria.in","r");
    fscanf(f,"%d",&n);
    fscanf(f,"%lf%lf",&x0,&y0);
    x1=x0;y1=y0;
    for(i=2;i<=n;i++)
    {
        fscanf(f,"%lf%lf",&x2,&y2);
        S+=0.5*(x1*y2-y1*x2);
        x1=x2;y1=y2;
    }
    S+=0.5*(x2*y0-y2*x0);
    fclose(f);
    ofstream fout("aria.out");
    fout<<setw(6)<<setiosflags(ios::fixed|ios::showpoint)<<setprecision(5)<<S;
    return 0;
}