include iostream include cmath using namespace std float float float f

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <iostream>
#include <cmath>
using namespace std;
//float p=2.0,l=1.0, m=2.0, o=1.5, k=1.0, s=2.5;
//float g=4.0,h=2.0, j=4.0, t=3.0, b=2.0, n=5.0;
float p,l,m,o,k,s,h,j,t,n,g,b,c;
float q,w,e,x,v;
class triangle {
public:
triangle();
triangle(double x1_, double y1_, double x2_, double y2_, double x3_, double y3_) {
x1 = x1_;
y1 = y1_;
x2 = x2_;
y2 = y2_;
x3 = x3_;
y3 = y3_;
a = length(x1, y1, x2, y2);
b = length(x2, y2, x3, y3);
c = length(x3, y3, x1, y1);
}
double length(double, double, double, double);
float medianatoQ(float,float,float);
float medianatoW(float,float,float);
float medianatoE(float,float,float);
float medianatoMin(void);
//int Similarity(float,float,float,float,float,float);
//float get_square(float ,float ,float );
// float get_square1(float ,float ,float );
int check(float ,float ,float ,float , float , float );
int operator ^(const triangle &);
float operator +(const triangle &);
float S,S1;
bool isRight();
double GetLen(int);
//double GetLen(int) { return a; return b; return c; }
private:
double x1, y1;
double x2, y2;
double x3, y3;
double a, b, c;
};
double triangle::length(double x1_, double y1_, double x2_, double y2_) {
return sqrt((x2_ - x1_) * (x2_ - x1_) + (y2_ - y1_) * (y2_ - y1_));
}
/*
bool triangle::isRight() {
if ((sqrt(a * a + b * b) == c) || (sqrt(a * a + c * c) == b))
return true;
return false;
}
*/
double triangle::GetLen(int k) {
double arr[3] = {a, b, c};
return arr[k];
}
/*
float triangle::medianatoQ(float q,float w,float e){
return 0.5*sqrt((2*w*w)+(2*e*e)-(q*q));}
float triangle::medianatoW(float q,float w,float e){
return 0.5*sqrt((2*q*q)+(2*e*e)-(w*w));}
float triangle::medianatoE(float q,float w,float e){
return 0.5*sqrt((2*q*q)+(2*w*w)-(e*e));}
*/
float triangle::medianatoMin(void){
float r;r=min(a,min(b,c));
cout<<r<<endl;
if(a==r)
return 0.5*sqrt((2*b*b)+(2*c*c)-(a*a));
if(b==r)
return 0.5*sqrt((2*a*a)+(2*c*c)-(b*b));
if(c==r)
return 0.5*sqrt((2*a*a)+(2*b*b)-(c*c));
}
/*
int Similarity(float q,float w,float e,float x, float c, float v){
if (((q / x) && (w/c) && (e / v)) ||
((w / x) && (e/c) && (q/v)) ||
((e/x) && (q/c) && (w/v)))
{
cout << "Да" << endl;
return 1;
}
else
{ cout << "Нет" << endl;
return 0;
}
}
/*
float get_square(float q,float w,float e){
float P = (q + w + e) / 2.0;
float S = sqrt(P * (P - q) * (P - w) * (P - e));
// printf("sq_trg0= %lf \n", S);
return S;
}
float get_square1(float x, float c, float v){
float p = (x + c + v) / 2.0;
//cout<<p<<endl;
float S = sqrt((p * (p-x) * (p-c) * abs((p-v))));
cout<<S;
return S;
}
*/
int triangle::operator ^ (const triangle &second)
{
// triangle trg(p,l,m,o,k,s);
//triangle trg1(g,h,j,t,b,n);
if (((q / x) && (w/c) && (e / v)) ||
((w / x) && (e/c) && (q/v)) ||
((e/x) && (q/c) && (w/v)))
{
cout << "Да" << endl;
return 1;
}
else
{ cout << "Нет" << endl;
return 0;
}
}
float triangle::operator + (const triangle &second)
{
float P = (q + w + e) / 2.0;
float S = sqrt(P * (P - q) * (P - w) * (P - e));
// printf("sq_trg0= %lf \n", S);
float p = (x + c + v) / 2.0;
//cout<<p<<endl;
float s = sqrt((p * (p-x) * (p-c) * abs((p-v))));
//cout<<(S+s)<<endl;
cout<<"Сумма площадей :";
return S+s;
}
int main() {
setlocale(LC_ALL, "Russian");
cout<<"Введите координаты вершин треугольника АВС"<<endl;
cin>>p>>l>>m>>o>>k>>s;
cout<<"Введите координаты вершин треугольника DEF"<<endl;
cin>>g>>h>>j>>t>>b>>n;
triangle trg(p,l,m,o,k,s);
triangle trg1(g,h,j,t,b,n);
// float q,w,e,k,x,c,v;
q=trg.GetLen(0);
w=trg.GetLen(1);
e=trg.GetLen(2);
x=trg1.GetLen(0);
c=trg1.GetLen(1);
v=trg1.GetLen(2);
std::cout<<"a:"<<q<<"\t"<<"b:"<<w<<"\t"<<"c:"<<e<<endl;
std::cout<<"d:"<<x<<"\t"<<"e:"<<c<<"\t"<<"f:"<<v<<endl;
std::cout<<"Медиана к наименьшей стороне :"<<trg.medianatoMin()<<endl;
std::cout<<"Подобны:";(trg^trg1);
//std::cout<<(trg^trg1);
std::cout<<(trg+trg1);
return 0;
}