Pagini recente » Cod sursa (job #969032) | Cod sursa (job #2309383) | Cod sursa (job #271863) | Rating Super Smecher (Super) | Cod sursa (job #1871269)
#include <fstream>
#include <vector>
#include <iomanip>
using std::pair;
using std::vector;
std::ifstream in("aria.in");
std::ofstream out("aria.out");
int n;
vector< pair<double, double> > coord;
double aria;
double mod(double thing) { if (thing < 0) thing = -thing; return thing; }
int main(void) {
std::ios::sync_with_stdio(false);
in >> n;
coord.reserve(n);
for (double i = 0; i < n; i++) {
pair<double, double> temp;
in >> temp.first >> temp.second;
coord.push_back(temp);
}
for (double i = 0; i < n - 1; i++) {
double h = coord[i + 1].first - coord[i].first;
double baze = coord[i + 1].second + coord[i].second;
aria += (((double)(h * baze)) / 2);
}
{
double h = coord[0].first - coord[n - 1].first;
double baze = coord[0].second + coord[n - 1].second;
aria += (((double)(h * baze)) / 2);
}
out << std::setprecision(10.5) << mod(aria);
}