Pagini recente » Cod sursa (job #769363) | Cod sursa (job #1073958) | Cod sursa (job #2249022) | Cod sursa (job #700580) | Cod sursa (job #1093720)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream f ("aria.in");
ofstream g ("aria.out");
int n;
double arie;
struct punct {
double x, y;
};
double arieTriunghi (punct a, punct b, punct c) {
return abs ( ((b.x-a.x) * (c.y-a.y) - (c.x-a.x) * (b.y-a.y))/2 );
}
void rezolva () {
f>>n;
punct p1, p[4];
if (n < 3) g<<0;
else {
f>>p[1].x>>p[1].y>>p[2].x>>p[2].y>>p[3].x>>p[3].y;
arie = arieTriunghi (p[1], p[2], p[3]);
for (int i=4; i<=n; i++) {
p[2] = p[3];
f>>p[3].x>>p[3].y;
arie=arie + arieTriunghi (p[1], p[2], p[3]);
}
g<<arie<<'\n';
}
}
int main () {
rezolva ();
return 0;
}