Pagini recente » Cod sursa (job #2347570) | Cod sursa (job #2600027) | Cod sursa (job #2070691) | Cod sursa (job #1809591) | Cod sursa (job #2072116)
#include <fstream>
#include <cmath>
#include <iostream>
/*#include <algorithm>*/
using namespace std;
struct punct{
double x, y;
};
int N, S;
punct P[1500];
/*bool compara(punct A, punct B){
return A.x+A.y<B.x+B.y;
}*/
bool egale(double a, double b){
return fabs(a-b)<0.003;
}
double distanta(punct A, punct B){
return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}
/*bool gaseste(punct A, punct B, int i, double dist){
int j, m;
double dn, dm;
j=N-1;
while (i<=j){
m=(i+j)/2;
dn=distanta(A, P[m]); dm=distanta(B, P[m]);
if (egale(dn, dm) && egale(dn, dist))
return true;
if (dn<dist)
i=m+1;
else
j=m-1;
}
return false;
}*/
int main(){
int i, j;
ifstream fin ("triang.in");
fin >> N;
for (i=0; i<N; i++)
fin >> P[i].x >> P[i].y;
fin.close();
/*sort(P, P+N, compara);*/
/*for (i=0; i<N-2; i++)
for (j=0; j<N-1; j++)
if (gaseste(P[i], P[j], j+1, distanta(P[i], P[j])))
S++;*/
for (i=0; i<N-2; i++)
for (j=i+1; j<N-1; j++)
for (int k=j+1; k<N; k++)
if (i!=j && j!=k && i!=k && egale(distanta(P[i], P[j]), distanta(P[i], P[k])) && egale(distanta(P[i], P[j]), distanta(P[j], P[k])))
S++;
ofstream fout ("triang.out");
fout << S << '\n';
fout.close();
return 0;
}