Pagini recente » Cod sursa (job #1461654) | Cod sursa (job #2464481) | Cod sursa (job #2345901) | Cod sursa (job #2112991) | Cod sursa (job #1229724)
#include <stdio.h>
#include <math.h>
#include <assert.h>
#define MAX 100005
#define FIN "aria.in"
#define FOUT "aria.out"
struct Point {
double x;
double y;
};
int N;
double Sum;
struct Point vector_of_points[ MAX ];
FILE *fin, *fout;
void readAndSolve();
int main() {
readAndSolve();
return 0;
};
void readAndSolve() {
int i;
fin = fopen(FIN, "r");
fout = fopen(FOUT, "w");
fscanf(fin, "%d", &N);
assert(1<=N && N <= 100000);
for(i = 0; i < N; ++i) {
fscanf(fin, "%lf %lf", &vector_of_points[i].x, &vector_of_points[i].y);
}
vector_of_points[ N ] = vector_of_points[ 0 ];
for(i = 0; i < N; ++i) {
Sum += (vector_of_points[ i ].x * vector_of_points[ i + 1 ].y - vector_of_points[ i + 1 ].x * vector_of_points[ i ].y);
}
fprintf(fout, "%.lf", fabs( Sum / 2.0 ));
fclose( fin );
fclose( fout );
};