Pagini recente » Cod sursa (job #3171677) | Cod sursa (job #1493723) | Cod sursa (job #1393512) | Cod sursa (job #400949) | Cod sursa (job #2352696)
/*#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;
ifstream fi ("aria.in");
ofstream fo ("aria.out");
struct point {
long long x, y;
};
point P[100001];
int n;
double AREA;
double triangle_area (point A, point B, point C)
{
A.x -= C.x;
B.x -= C.x;
A.y -= C.y;
B.y -= C.y;
return fabs (double ((A.x * B.y - B.x * A.y) / 2));
}
int main()
{
fi >> n;
for (int i = 1; i <= n; ++ i)
fi >> P[i].x >> P[i].y;
for (int i = 2; i <= n - 1; ++ i)
AREA += triangle_area (P[1], P[i], P[i + 1]);
fo << AREA;
fi.close ();
fo.close ();
return 0;
}*/
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
#define NMax 100010
struct Punct{
long double x, y;
};
typedef Punct Poligon[NMax];
int n;
Poligon P;
void citire();
long double aria(Poligon &);
long double abs(long double x) {return (x < 0) ? -x : x;}
int main(){
citire();
fout << fixed << setprecision(5) << aria(P);
}
void citire(){
int i;
fin >> n;
for(i = 1; i <= n; i++) fin >> P[i].x >> P[i].y;
P[0] = P[n];
P[n + 1] = P[1];
}
long double aria(Poligon & P){
int i;
long double a = 0;
for(i = 1; i <= n; i++)
a += P[i].x * (P[i + 1].y - P[i - 1].y);
return abs(a) / 2;
}