Pagini recente » Cod sursa (job #1822089) | Cod sursa (job #507514) | Cod sursa (job #1534570) | Cod sursa (job #1736789) | Cod sursa (job #1504104)
#include <fstream>
#include <vector>
#include <cmath>
using namespace std;
ifstream is("aria.in");
ofstream os("aria.out");
struct Punct{
double x, y;
} in, a, b;
int n;
double s;
double Aria(Punct A, Punct B);
int main()
{
is >> n;
is >> a.x >> a.y;
in.x = a.x; in.y = a.y;
for ( int i = 2; i <= n; ++i )
{
is >> b.x >> b.y;
s += Aria(a, b);
a = b;
}
s += Aria(a, in);
os << abs(s / 2);
is.close();
os.close();
return 0;
}
double Aria(Punct A, Punct B)
{
return A.x * B.y - A.y * B.x;
}