Cod sursa(job #2653100)

Utilizator raikadoCri Lu raikado Data 26 septembrie 2020 21:05:22
Problema Aria Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <fstream>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	ifstream fin("aria.in");
	ofstream fout("aria.out");

	int N; 
	fin >> N;

	float x0, y0, x1, y1;
	fin >> x0 >> y0;
	x1 = x0; y1 = y0;

	float A = 0;
	for (int i = 1; i < N; i++)
	{
		float x2, y2;
		fin >> x2 >> y2;

		A += (x1 * y2 - x2 * y1);
		x1 = x2; y1 = y2;
	}

	A += (x1 * y0 - x0 * y1);
	A /= 2;

	fout << A;

	return 0;
}