-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathint_triangle_old.cpp
More file actions
38 lines (35 loc) · 1.28 KB
/
int_triangle_old.cpp
File metadata and controls
38 lines (35 loc) · 1.28 KB
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
#include <iostream>
#include <cmath>
using namespace std;
bool isPerfectSquare(long double n){
long double intpart; // целая часть
return n>3 && modfl(sqrt(n), &intpart) == 0.0 ;
}
int main(int argc, char* argv[]) {
cout.precision(20);
if (argc > 1)// если передаем аргументы, то argc будет больше 1(в зависимости от кол-ва аргументов)
{
long long ar1 = stoi(argv[1]);
long long ar2 = stoi(argv[2]);
long long ar3 = stoi(argv[3]);
for(long long a = ar1 ; a < ar2; a++)
{
if (a % 100 == 0) cout << "a=" << a << std::endl;
for(long long b = a+1; b < ar3; b++)
{
long double p=(a+b+b)/2-0.5;
for(long long c = b; c < a+b; c++)
{
p+=0.5;
if (isPerfectSquare(p*(p-a)*(p-b)*(p-c)) && isPerfectSquare(2*b*b+2*c*c-a*a) && isPerfectSquare(2*a*a+2*c*c-b*b) && isPerfectSquare(2*a*a+2*b*b-c*c))
{
std::cout << a << " " << b << " " << c << " ";
std::cout << (sqrt(2*b*b+2*c*c-a*a))/2 << " " << (sqrt(2*a*a+2*c*c-b*b))/2 << " " << (sqrt(2*a*a+2*b*b-c*c))/2 << " ";
std::cout << sqrt((p*(p-a)*(p-b)*(p-c))) << std::endl;
}
}
}
}
}
return 0;
}