Pagini recente » Cod sursa (job #1457591) | Cod sursa (job #1029396) | Cod sursa (job #352284) | Cod sursa (job #19544) | Cod sursa (job #1826879)
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
struct Point{
double x, y;
}point[100001];
double area(int n) {
double x1,x2,x3,y2,y3,s;
x1 = point[1].x;
y3 = point[1].y;
for(int i=2; i<n; ++i) {
x2 = point[i].x;
y2 = point[i].y;
s += (x1 * y2 - x2 * y3);
x1 = x2;
y3 = y2;
}
s += (x2*point[1].y - point[1].x * y2);
return s;
}
int main()
{
int i,n;
ifstream f("aria.in");
f >> n;
for(i = 1 ; i <= n ; ++i)
f >> point[i].x >> point[i].y;
ofstream g("aria.out");
g << fixed << setprecision(6) << area(n);
return 0;
}