Cod sursa(job #1504104)
| Utilizator | Data | 17 octombrie 2015 12:25:05 | |
|---|---|---|---|
| Problema | Aria | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.59 kb |
#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;
}
