Pagini recente » Cod sursa (job #3146282) | Cod sursa (job #2404651) | Cod sursa (job #549674) | Cod sursa (job #499400) | Cod sursa (job #2299297)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("aria.in");
ofstream fout ("aria.out");
int n,i,a,s;
struct punct{
double x,y;
}v[1000],p;
int c_p(punct a, punct o, punct b)
{
int d=( a.x - o.x ) * ( b.y - o.y ) - ( b.x - o.y) * ( a.y - o.y );
return d;
if(d==0)return 1;
else if(d<0)return 2;
else if(d>0)return 3;
}
int main()
{
fin>>n;
for(i=1;i<=n;i++)
{
fin>>v[i].x>>v[i].y;
}
p.x=0;
p.y=0;
for(i=1;i<=n;i++)
{
a=c_p(v[i],p,v[i+1])/2;
s=s+a;
}
a=c_p(v[n],p,v[1])/2;
s=s+a;
fout<<s;
return 0;
}