Cod sursa(job #2213985)
Utilizator | Georgescu Dan cameleon | Data | 18 iunie 2018 11:06:19 |
---|---|---|---|
Problema | Aria | Scor | 70 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <fstream>
#include <iomanip>
using namespace std;
ifstream f("aria.in");
ofstream g("aria.out");
int i,n;
double atot;
struct hh{
double x,y;
};
hh a,b,a1;
double arie(double x1,double y1,double x2,double y2)
{
return x1*y2-y1*x2;
}
int main()
{
f>>n;
f>>a.x>>a.y;
a1=a;
for(i=2;i<=n;i++)
{
f>>b.x>>b.y;
atot+=arie(a.x,a.y,b.x,b.y);
a=b;
}
atot+=arie(b.x,b.y,a1.x,a1.y);
atot=atot/2;
g<<fixed<<setprecision(6)<<atot;
}