Cod sursa(job #1059119)

Utilizator Juve45UAIC Alexandru Ionita Juve45 Data 16 decembrie 2013 11:02:59
Problema Aria Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.76 kb
#include <fstream>
#include <vector>
#include <iomanip>
#define dmax 100000

using namespace std;

ifstream fin("aria.in");
ofstream fout("aria.out");

struct point {
    double x,y;
    } v[dmax];
int n;
double s;

//functions declaration
void read();
//reads the input file

double area(point x1, point x2);
// calculates the area of the triangle formed by the two points x1 & x2 with the origin O(0,0)



int main() {

read();
for(int i=0;i<n-1;i++)
    s=s+area(v[i],v[i+1]);

s=s+area(v[n-1],v[0]);

fout << setprecision(5) << s;

    return 0;
    }


void read() {

    fin>>n;

    for(int i=0; i<n; i++)
        fin>>v[i].x>>v[i].y;

    }

double area(point p1, point p2) {

return (p1.x*p2.y-p2.x*p1.y)/2;

    }