Mai intai trebuie sa te autentifici.
Cod sursa(job #1484154)
| Utilizator | Data | 10 septembrie 2015 15:32:12 | |
|---|---|---|---|
| Problema | Aria | Scor | 100 |
| Compilator | c | Status | done |
| Runda | Arhiva educationala | Marime | 0.63 kb |
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
FILE* fin = fopen("aria.in", "r");
int n;
fscanf(fin, "%d\n", &n);
long double* x = malloc((n + 1) * sizeof(long double));
long double* y = malloc((n + 1) * sizeof(long double));
int i;
for(i=0; i<n; i++) {
fscanf(fin, "%Lf %Lf\n", &x[i], &y[i]);
}
fclose(fin);
x[n] = x[0];
y[n] = y[0];
long double res = 0.0;
for(i=0; i<n; i++) {
res = res + x[i] * y[i + 1] - x[i + 1] * y[i];
}
res = fabs(res / 2.0);
FILE* fout = fopen("aria.out", "w");
fprintf(fout, "%Lf\n", res);
free(x);
free(y);
fclose(fout);
return 0;
}