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
| bool check2(double a, double b, double c) {
bool positive = (a > 0) && (b > 0) && (c >0);
if (positive) {
bool abc = (a + b) > c;
bool bca = (b + c) > a;
bool acb = (a + c) > b;
return abc && bca && acb;
}
return false;
}
void plos(int n){
double x1, y1, x2, y2, x3, y3, P, r, S, AB, BC, AC;
cout << "Введите значения всех x, y:\n";
cout << "x1="; cin >> x1;
cout << "y1="; cin >> y1;
cout << "x2="; cin >> x2;
cout << "y2="; cin >> y2;
cout << "x3="; cin >> x3;
cout << "y3="; cin >> y3;
AB = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
BC = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
AC = sqrt(pow(x3 - x1, 2) + pow(y3 - y1, 2));
if(check2(AB,BC,AC)){
P = AB + BC + AC;
r = P / 2.0;
S = sqrt(r * ( r - AB) * (r - BC ) * (r - AC));
cout << "S = " << S << '\n';}else cout<<"Треугольник не существует!";
{MAX}
cout<<"\nMax: "<<max<<endl;}
int _tmain(int argc, _TCHAR* argv[])
{
setlocale(0,"rus");
cout<<"Введите кол-во треугольников:\t"<<endl;
int n,i;
cin>>n;
for(i=0;i<n;i++){
plos(n);}
_getch();
return 0;
} |