Pagini recente » Cod sursa (job #1140664) | Cod sursa (job #2909976) | Cod sursa (job #1190114) | Cod sursa (job #698909) | Cod sursa (job #1225814)
#include <fstream>
#include <iomanip>
using namespace std;
int main ()
{
int N;
long double x1, x2, y1, y2, x0, y0, Aria = 0;
ifstream fin ("aria.in");
ofstream fout ("aria.out");
fin >> N;
fin >> x1 >> y1;
x0 = x1;
y0 = y1;
for (int i = 1; i < N; i++)
{
fin >> x2 >> y2;
Aria += x1 * y2 - x2 * y1;
x1 = x2;
y1 = y2;
}
Aria += x1 * y0 - x0 * y1;
if (Aria < 0) Aria = -Aria;
fout << fixed << setprecision (6) << Aria * 0.5;
fin.close ();
fout.close ();
return 0;
}