Mai intai trebuie sa te autentifici.
Cod sursa(job #2014650)
Utilizator | Data | 24 august 2017 11:32:32 | |
---|---|---|---|
Problema | Aria | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.76 kb |
#include <fstream>
#include <vector>
#include <iomanip>
using namespace std;
ifstream cin("aria.in");
ofstream cout("aria.out");
double det(pair < double, double > a, pair < double, double > b, pair < double, double > c) {
double d = (a.first * b.second) + (b.first * c.second) + (c.first * a.second) -
(a.second * b.first) - (b.second * c.first) - (c.second * a.first);
return d / 2.0f;
}
int main() {
int n;
cin >> n;
vector < pair < double, double > > v(n + 1);
double aria = 0;
pair < double, double > p = {100, 100};
for (int i = 0; i < n ; i ++) {
double x, y;
cin >> x >> y;
v[i] = {x, y};
}
for (int i = 0; i < n; i++) {
aria += det(v[i], v[(i + 1)% n], p);
}
cout << fixed << setprecision(7) << aria << '\n';
}