Pagini recente » Cod sursa (job #2195377) | Cod sursa (job #197426) | Cod sursa (job #2086440) | Cod sursa (job #119525) | Cod sursa (job #614286)
Cod sursa(job #614286)
#include <iostream>
#include <fstream>
//#include <conio.h>
#include <cstdlib>
#include <math.h>
using namespace std;
struct Punct{
double x;
double y;
};
int main()
{
Punct p[1500];
int n,k=0;
double l1,l2,l3;
ifstream myfile1 ("triang.in");
ofstream myfile2 ("triang.out");
if (myfile1.is_open())
{
while (! myfile1.eof())
{
myfile1>>n;
//Punct p[];
for(int i=0; i<n; i++)
{
myfile1>>p[i].x >>p[i].y;
}
}
myfile1.close();
}
for(int i=0; i<n; i++)
{
l1=sqrt((p[i].x-p[i+1].x)*(p[i].x-p[i+1].x)+(p[i].y-p[i+1].y)*(p[i].y-p[i+1].y));
l2=sqrt((p[i].x-p[i+2].x)*(p[i].x-p[i+2].x)+(p[i].y-p[i+2].y)*(p[i].y-p[i+2].y));
l3=sqrt((p[i+2].x-p[i+1].x)*(p[i+2].x-p[i+1].x)+(p[i+2].y-p[i+1].y)*(p[i+2].y-p[i+1].y));
if(l1==l2==l3)k++;
}
myfile2<<k;
myfile2.close();
//getch();
return 0;
}