Pagini recente » Istoria paginii runda/cerculdeinfo-lectia15-ev_p_s_q_dq_dp/clasament | Cod sursa (job #1011791) | Cod sursa (job #499098) | Cod sursa (job #2712640) | Cod sursa (job #2483390)
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
ifstream f("triang.in");
ofstream g("triang.out");
double distanta(double x1, double y1, double x2, double y2)
{
double rezultat,xp,yp;
xp=(x2-x1)*(x2-x1);
yp=(y2-y1)*(y2-y1);
rezultat=sqrt(xp+yp);
return rezultat;
}
int n,i,j,p,cnt,nr;
double eroare=0.001,distanta1,distanta2,distanta3;
struct coordonate
{
double x,y;
}v[1501];
int main()
{
f>>n;
for(i=1;i<=n;i++)
f>>v[i].x>>v[i].y;
for(i=1;i<=n-2;i++)
for(j=i+1;j<=n-1;j++)
for(p=j+1;p<=n;p++)
{
cnt=0;
distanta1=distanta(v[i].x,v[i].y,v[j].x,v[j].y);
distanta2=distanta(v[j].x,v[j].y,v[p].x,v[p].y);
distanta3=distanta(v[i].x,v[i].y,v[p].x,v[p].y);
if(abs(distanta1-distanta2)<=eroare)
cnt++;
if(abs(distanta3-distanta2)<=eroare)
cnt++;
if(abs(distanta3-distanta1)<=eroare)
cnt++;
if(cnt==3)
nr++;
}
g<<nr;
return 0;
}