Pagini recente » Cod sursa (job #724760) | Cod sursa (job #547319) | Cod sursa (job #344211) | Cod sursa (job #919861) | Cod sursa (job #2146638)
#include <bits/stdc++.h>
using namespace std;
ofstream fout("aria.out");
struct Dublu
{
double x, y;
}a[100005];
int n;
void Read()
{
ifstream fin("aria.in");
fin >> n;
for (int i = 1; i <= n; i++)
fin >> a[i].x >> a[i].y;
a[++n] = a[1]; // inchid ciclul
fin.close();
}
/**
| 0 0 1| //origine
| x1 y1 1| // punctul1
| x2 y2 1| // punctul2
y1 + x1*y2 + x2 - x2*y1 - x2 - y2 = x1*y2 - x2*y1
*/
int main()
{
long double sol = 0;
long double x = 0;
Read();
for (int i = 2; i <= n; i++)
{
x = (a[i - 1].x * a[i].y - a[i - 1].y * a[i].x); /// determinant
sol += x;
}
fout << setprecision(5) << fixed << 0.5 * sol << "\n";
return 0;
}