Pagini recente » Cod sursa (job #2223267) | Cod sursa (job #1055607) | Cod sursa (job #561622) | Cod sursa (job #2566146) | Cod sursa (job #1812375)
#include <cstdio>
double det(double ax, double ay, double bx, double by, double cx, double cy) {
return ax * by +
bx * cy +
cx * ay -
ax * cy -
bx * ay -
cx * by;
}
const int MAX_P = 100000;
double x[MAX_P], y[MAX_P];
int main() {
int n, j;
double arie;
FILE *fin = fopen("aria.in", "r");
fscanf(fin, "%d", &n);
for(int i = 0; i < n; ++i)
fscanf(fin, "%lf%lf", &x[i], &y[i]);
fclose(fin);
arie = 0LL;
for(int i = 0; i < n; ++i) {
j = (i + 1) % n;
arie = arie + det(0.0f, 0.0f, x[i], y[i], x[j], y[j]);
}
FILE *fout = fopen("aria.out", "w");
if(arie < 0)
arie = -arie;
fprintf(fout, "%lf", arie / 2);
fclose(fout);
return 0;
}