Pagini recente » Cod sursa (job #1661262) | Cod sursa (job #1051161) | Cod sursa (job #965916) | Cod sursa (job #2394650) | Cod sursa (job #1775715)
//
// main.cpp
// Aria
//
// Created by Albastroiu Radu on 10/10/16.
// Copyright © 2016 Albastroiu Radu. All rights reserved.
//
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <unordered_map>
#include <vector>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
long long i, n;
double h, m, x, y, A;
struct pn
{
long long x, y;
}punct, last;
vector<pn> puncte;
// Punctul de test este ( 0, 0 )
double aria(double x1, double x2, double y1, double y2)
{
return x1*y2 - y1*x2;
}
int main()
{
fin >> n;
for(i=1;i<=n;i++)
{
fin >> x >> y;
punct.x = x;
punct.y = y;
puncte.push_back(punct);
}
last.x = puncte[n-1].x;
last.y = puncte[n-1].y;
for (i=0;i<n;i++)
{
A += aria(last.x, puncte[i].x, last.y, puncte[i].y);
last.x = puncte[i].x;
last.y = puncte[i].y;
}
fout << A/2;
return 0;
}