Pagini recente » Cod sursa (job #2299535) | Cod sursa (job #496623) | Cod sursa (job #2506585) | Cod sursa (job #1048825) | Cod sursa (job #1611150)
#include <iostream>
#include <cstdio>
#include <algorithm>
#define Point pair<double,double>
using namespace std;
Point v[100005], O;
int N;
double det(Point A, Point B, Point C)
{
return (A.first-C.first)*(B.second-C.second) - (A.second-C.second)*(B.first-C.first);
}
bool cmp(Point A, Point B)
{
return det(v[1],A,B)>0;
}
void citire()
{
freopen("aria.in","r",stdin);
scanf("%d",&N);
int pos = 1;
for(int i=1; i<=N; i++)
{
scanf("%lf%lf",&v[i].first,&v[i].second);
if(v[pos]>v[i])
{
pos = i;
}
}
//swap(v[1],v[pos]);
}
void solve()
{
double Arie=0;
//sort(v+1,v+N+1,cmp);
v[N+1] = v[1];
for(int i=1; i<=N; i++)
Arie = Arie + (v[i].first * v[i+1].second - v[i+1].first * v[i].second);
Arie = Arie/2;
freopen("aria.out","w",stdout);
printf("%lf",Arie);
}
int main()
{
citire();
solve();
return 0;
}