Cod sursa(job #1614963)

Utilizator laura.calimanLaura Caliman laura.caliman Data 26 februarie 2016 12:26:21
Problema Aria Scor 20
Compilator fpc Status done
Runda Arhiva educationala Marime 0.65 kb
var n,i,k:longint;
    s:real;
    x,y:array[1..100000] of real;
    
function aria(x1,y1,x2,y2:real):real;
begin
  aria:=x1*y2-x2*y1;
end;
    
begin
  assign(input,'aria.in');
  assign(output,'aria.out');
  reset(input);
  rewrite(output);
  read(n);
  for i:=1 to n do read(x[i],y[i]);
  s:=0;
  for i:=1 to n-1 do begin
    s:=s+aria(x[i],y[i],x[i+1],y[i+1]);
    s:=s*100000;
    if s>=0 then begin
      k:=round(s);
      s:=k/100000;
    end else begin
      k:=round(s);
      s:=-k/100000;
    end;
  end;
  s:=s+aria(x[n],y[n],x[1],y[1]);
  s:=s*100000;
  s:=round(s);
  s:=trunc(s)/100000;
  write(abs(s/2):2:5);
end.