Pagini recente » Cod sursa (job #1212631) | Cod sursa (job #2938502) | Cod sursa (job #426438) | Cod sursa (job #30325) | Cod sursa (job #2154745)
#include <fstream>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct punct{
long double x, y;
};
inline long double det(punct c1, punct c2, punct c3) {
long double delta = c1.x * c2.y + c2.x * c3.y + c1.y * c3.x - c2.y * c3.x - c1.x * c3.y - c2.x * c1.y;
if (delta < 0) delta *= -1;
long double sol = delta / (long double) 2;
return sol;
}
inline void Read() {
int N;
punct start, ante, curent;
fin >> N; long double s = 0;
fin >> start.x >> start.y;
fin >> ante.x >> ante.y;
for (int i = 3; i <= N; i++) {
fin >> curent.x >> curent.y;
s += det(start, ante, curent);
ante = curent;
}
fout << fixed << setprecision(5) << s;
}
int main () {
Read();
fin.close(); fout.close(); return 0;
}