Cod sursa(job #3200365)
Utilizator | Mihai Popescu Mihai_Popescu | Data | 4 februarie 2024 14:22:38 |
---|---|---|---|
Problema | Aria | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.52 kb |
#include <fstream>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
int main() {
int n;
fin >> n;
double x1, y1;
fin >> x1 >> y1;
double x0 = x1, y0 = y1;
double arie = 0;
for (int i = 2; i <= n; ++i) {
double x2, y2;
fin >> x2 >> y2;
arie += (x1 * y2 - x2 * y1) / 2.0;
if (i == n) {
arie += (x2 * y0 - x0 * y2) / 2.0;
}
x1 = x2;
y1 = y2;
}
fout << arie;
return 0;
}