Pagini recente » Cod sursa (job #1461057) | Cod sursa (job #1388844) | Cod sursa (job #1567160) | Cod sursa (job #2123714) | Cod sursa (job #1025646)
#include<iostream>
#include<fstream>
#include<functional>
#include<math.h>
#include<map>
#define PI 3.141592653
#define ax imt->first.first
#define ay imt->first.second
#define bx jmt->first.first
#define by jmt->first.second
using namespace std;
int n, k;
double x, y, a, b;
ifstream f("triang.in");
ofstream g("triang.out");
map< pair<double, double>, int> m;
map< pair<double, double>, int>::iterator imt, jmt;
pair<double, double> p;
const double eps = 1e-3;
double si=0.8660254, co=0.5;
int main()
{
f>>n;
for(int i=0; i<n; ++i) {
f>>x>>y;
x = round(x * 1000.0) / 1000.0;
y = round(y * 1000.0) / 1000.0;
m[make_pair(x, y)]=1;
}
for(imt=m.begin(); imt!=m.end(); ++imt){
jmt=imt;++jmt;
for(; jmt!=m.end(); ++jmt){
cout<<"puncte:\n"<<ax<<' '<<ay<<'\n';
cout<<bx<<' '<<by<<"\n--------\n";
a=ax+co*(bx-ax)-si*(by-ay);
b=ay+si*(bx-ax)+co*(by-ay);
a=round(a*1000.0)/1000.0;
b=round(b*1000.0)/1000.0;
p=make_pair(a,b);
cout<<p.first<<' '<<p.second<<'\n';
if(m.find(p)!=m.end()) ++k, cout<<"da\n\n";
else cout<<"nu \n\n";
a=ax+co*(bx-ax)+si*(by-ay);
b=ay-si*(bx-ax)+co*(by-ay);
a = round(a * 1000.0) / 1000.0;
b = round(b * 1000.0) / 1000.0;
p=make_pair(a, b);
cout<<p.first<<' '<<p.second<<'\n';
if(m.find(p)!=m.end())++k, cout<<"da\n--------\n";
else cout<<"nu \n\--------\n";
}
}
cout<<'\n';
for(imt=m.begin(); imt!=m.end(); ++imt)
cout<<ax<<' '<<ay<<'\n';
g<<k/3; cout<<k;
return 0;
}