Pagini recente » Cod sursa (job #993742) | Statistici Gabriel Marghescu (Marghescu) | Cod sursa (job #743239) | Profil Sasha_12454 | Cod sursa (job #1517110)
#include <fstream>
using namespace std;
int n;
long double firstX;
long double firstY;
int main(void)
{
fstream fin("aria.in",ios::in);
fstream fout("aria.out",ios::out);
long double result = 0.0f;
fin >> n;
if (n >= 3)
{
fin >> firstX >> firstY;
long double tempX = firstX;
long double tempY = firstY;
n -= 1;
while (n > 0)
{
long double newX;
long double newY;
fin >> newX >> newY;
result += (tempX * newY - newX * tempY);
tempX = newX;
tempY = newY;
n -= 1;
}
long double newX = firstX;
long double newY = firstY;
result += (tempX * newY - newX * tempY);
}
fout.precision(20);
fout << (result * 0.5f) << endl;
fin.close();
fout.close();
return 0;
}