Pagini recente » Cod sursa (job #170264) | Cod sursa (job #2129100) | Cod sursa (job #2785877) | Cod sursa (job #1317538) | Cod sursa (job #1698323)
#include <cstdio>
#include <iostream>
using namespace std;
float terulet(float x, float y, float x1, float y1, float x2, float y2){
x1-=x;
y1-=y;
x2-=x;
y2-=y;
return x1*y2-x2*y1;
}
float abs(float d){
return d>=0?d:-d;
}
int main()
{
FILE* f=fopen("arie.in", "r");
int n;
fscanf(f, "%d", &n);
float x, y, x1, y1, x2, y2;
float ter=0;
fscanf(f, "%f %f", &x, &y);
fscanf(f, "%f %f", &x1, &y1);
for(int i=2;i<n;i++){
fscanf(f, "%f %f", &x2, &y2);
ter+=terulet(x, y, x1, y1, x2, y2);
x1=x2;
y1=y2;
}
fclose(f);
f=fopen("arie.out", "w");
ter=abs(ter)/2;
fprintf(f, "%f", ter);
return 0;
}