Pagini recente » Cod sursa (job #2804849) | Cod sursa (job #136500) | Cod sursa (job #330531) | Cod sursa (job #1523008) | Cod sursa (job #1871176)
#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 minx, miny;
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 (int i = 0; i < n; i++) {
pair<double, double> temp;
in >> temp.first >> temp.second;
if (temp.first < minx) minx = temp.first;
if (temp.second < miny) miny = temp.second;
coord.push_back(temp);
}
for (int i = 0; i < n - 1; i++) {
int h = coord[i + 1].first - coord[i].first;
int baze = coord[i + 1].second + coord[i].second;
aria += (((double)(h * baze)) / 2);
}
{
int h = coord[n - 1].first - coord[0].first;
int baze = coord[n - 1].second + coord[0].second;
aria += (((double)(h * baze)) / 2);
}
out << std::setprecision(5) << std::fixed << mod(aria);
}