Pagini recente » Cod sursa (job #555205) | Cod sursa (job #1914556) | Cod sursa (job #472821) | Cod sursa (job #1912789) | Cod sursa (job #1871178)
#include <iostream>
#include <cstdio>
#define cout cerr
#define MAX 100001
using namespace std;
pair <float, float> puncte[MAX];
int n;
float x,y;
float A;
float Arie(int xa,int ya, int xb,int yb)
{
return xa*yb-ya*xb;
}
int main()
{
freopen("aria.in","r",stdin);
freopen("aria.out","w",stdout);
scanf("%d ",&n);
for(int i=1; i<=n; i++)
{
scanf("%f %f",&x,&y);
puncte[i]=make_pair(x,y);
}
for(int i=1; i<n; i++)
{
A+=Arie(puncte[i].first,puncte[i].second,puncte[i+1].first,puncte[i+1].second);
//cout<<puncte[i].first*puncte[i+1].second-puncte[i].second*puncte[i+1].second<<" __ ";
// cout<<puncte[i].first<<" "<<puncte[i].second<<" ~ "<<puncte[i+1].first<<" "<<puncte[i+1].second<<endl;
}
A+=puncte[n].first*puncte[1].second-puncte[n].second*puncte[1].second;
if(A>0)
printf("%f",A/2);
else printf("%f",-A/2);
return 0;
}