Pagini recente » Cod sursa (job #2083019) | Cod sursa (job #71301) | Cod sursa (job #1054047) | Cod sursa (job #1599997) | Cod sursa (job #1504100)
#include <fstream>
#include <vector>
using namespace std;
ifstream is("aria.in");
ofstream os("aria.out");
struct Punct{
double x, y;
} in, a, b;
int n;
double s;
int 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 << s;
is.close();
os.close();
return 0;
}
int Aria(Punct A, Punct B)
{
return ( A.x * B.y - A.y * B.x ) / 2;
}