Mai intai trebuie sa te autentifici.
Cod sursa(job #1802148)
| Utilizator | Data | 9 noiembrie 2016 21:50:27 | |
|---|---|---|---|
| Problema | Aria | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.65 kb |
// cu trapeze
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
#define lim 100010
struct hei{double x,y;};
hei ini[lim];
int n,i;
long double rez;
long double modul(long double x)
{
if(x<0)
return -x;
return x;
}
int main()
{
fin>>n;
for(i=1; i<=n; i++)
fin>>ini[i].x>>ini[i].y;
ini[n+1]=ini[1];
rez=0;
for(i=1; i<=n; i++)
rez+=( (ini[i].y+ini[i+1].y) * (ini[i+1].x-ini[i].x)/2 );
fout<<setprecision(5)<<fixed<<modul(rez);
fin.close();
fout.close();
return 0;
}
