Pagini recente » Cod sursa (job #1396997) | Cod sursa (job #2291345) | Cod sursa (job #99175) | Cod sursa (job #552619) | Cod sursa (job #2146646)
#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.0;
Read();
for (int i = 2; i <= n; i++)
sol += (a[i - 1].x * a[i].y - a[i - 1].y * a[i].x); /// determinant
fout << fixed << setprecision(7) << 0.5 * sol << "\n";
return 0;
}