Cod sursa(job #2226382)
| Utilizator | Data | 30 iulie 2018 09:16:35 | |
|---|---|---|---|
| Problema | Aria | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.75 kb |
#include <fstream>
#include <iomanip>
using namespace std;
long numberOfPoints, xPoint[1000001], yPoint[1000001];
int main() {
ifstream inputfile("aria.in");
ofstream outputfile("aria.out");
inputfile >> numberOfPoints;
for (int i = 1; i <= numberOfPoints; i++)
{
int xi,yi;
inputfile >> xi >> yi;
xPoint[i] = xi;
yPoint[i] = yi;
} // citirea numarului de punct si a coordonatelor acestora
long area;
for ( int i = 1; i <= numberOfPoints; i++)
{
area = area + (xPoint[i] * yPoint[i+1] - xPoint[i+1] * yPoint[i]);
}
area = area + (xPoint[numberOfPoints] * yPoint[1] - xPoint[1] * yPoint[numberOfPoints]);
outputfile << setprecision(6) << fixed << area / 2.0;
return 0;
}