Pagini recente » Cod sursa (job #3284877) | Cod sursa (job #2810240) | Cod sursa (job #2393196) | Cod sursa (job #3290994) | Cod sursa (job #2214796)
#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;
/*ifstream fin("ariatriunghi.in");
ofstream fout("ariatriunghi.out");*/
ifstream fin("aria.in");
ofstream fout("aria.out");
/*struct elev
{
char nume;//initiala; campul nume
float nota_mate,nota_info;//campul nota_mate, campul nota_info
int varsta;// campul varsta
};
elev ion;*///S-a declarat o variabila ion de tip elev
/*struct punct
{
float x,y;
};
punct a,b,c;
float det,mod_a,mod_b;*/
struct punct
{
float x,y;
};
punct v[100001];
float arie;
int n,i;
float arietriunghi(punct a,punct b,punct c)
{
float det=a.x*(b.y-c.y)-b.x*(a.y-c.y)+c.x*(a.y-b.y);
return abs(det)/2;
}
int main()
{
/*cin>>ion.varsta;// Am accesat campul varsta al variabilei ion
cin>>ion.nota_mate>>ion.nota_info;
cout<<ion.varsta<<" ";
cout<<ion.nota_info<<" "<<ion.nota_mate;*/
//Afisare ariei unui triunghi in functie de coordonatele x si y ale varfurilor
/*cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y;
det=a.x*b.y+b.x*c.y+c.x*a.y-c.x*b.y-a.y*b.x-a.x*c.y;
det=a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y);
cout<<abs(det)/2;*/
//Problema 4
/*cin>>a.x>>a.y>>b.x>>b.y;
if(a.x!=b.x||a.y!=b.y)
{
mod_a=sqrt(a.x*a.x+a.y*a.y);
cout<<mod_a<<'\n';
mod_b=sqrt(b.x*b.x+b.y*b.y);
cout<<mod_b<<'\n';
cout<<(a.x*b.x+a.y*b.y)/(mod_a*mod_b);
}
else
cout<<1;*/
//Aria triunghi-#928 pbinfo
/*struct punct
{
float x,y;
};
punct a,b,c;
float det,mod_a,mod_b;
fin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y;
det=a.x*b.y+c.x*a.y+b.x*c.y-c.x*b.y-
b.x*a.y-a.x*c.y;
det=a.x*(b.y-c.y)-b.x*(a.y-c.y)+c.x*(a.y-b.y);
fout<<fixed<<setprecision(1)<<abs(det)/2;*/
//Aria unui triunghi oarecare in functie de laturi
/*int a,b,c;
cin>>a>>b>>c;
int p=(a+b+c)/2;
cout<<double(sqrt(p*(p-a)*(p-b)*(p-c)));*/
fin>>n;
for(i=1;i<=n;i++)
fin>>v[i].x>>v[i].y;
for(i=1;i<=n-2;i++)
arie+=arietriunghi(v[1],v[i+1],v[i+2]);
fout<<arie;
return 0;
}