​经典算法无须注解​

/*
只能做凸的多边形
且必须一个时针输入
*/
#include<bits/stdc++.h>
using namespace std;
class Point{
public:
int x,y;
Point(){}
Point(int x,int y){
this->x = x;
this->y = y;
}
float getLength()
{
return sqrtf(x*x+y*y);
}
};
vector<Point> v;
float getArea(Point p1,Point p2,Point p3)
{
Point v1(p2.x-p1.x,p2.y-p1.y),v2(p3.x-p1.x,p3.y-p1.y);
cout << "area " << (v1.x*v2.y-v1.y*v2.x)/2.0 <<endl;
return (v1.x*v2.y+v1.y*v2.x)/2.0;
}
int main()
{
freopen("in.txt","r",stdin);
Point p1(0,0),p2(5,0),p3(0,13);
float areas = 0;
int n,x,y,m;
cin >> n;
m = n;
while(n--)
{
cin >> x >> y;
Point p(x,y);
v.push_back(p);
}
for(int i = 0;i < m-2;i++)
{
areas = getArea(v[0],v[i+1],v[i+2]);
}
cout << areas << endl;
}