-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythagoras.cpp
More file actions
44 lines (36 loc) · 946 Bytes
/
pythagoras.cpp
File metadata and controls
44 lines (36 loc) · 946 Bytes
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
// C++ program to implement
// the above approach
#include <bits/stdc++.h>
using namespace std;
// Function to check if right-angled
// triangle can be formed by the
// given coordinates
void checkRightAngled(int X1, int Y1,
int X2, int Y2,
int X3, int Y3)
{
// Calculate the sides
int A = (int)pow((X2 - X1), 2)
+ (int)pow((Y2 - Y1), 2);
int B = (int)pow((X3 - X2), 2)
+ (int)pow((Y3 - Y2), 2);
int C = (int)pow((X3 - X1), 2)
+ (int)pow((Y3 - Y1), 2);
// Check Pythagoras Formula
if ((A > 0 and B > 0 and C > 0)
and (A == (B + C) or B == (A + C)
or C == (A + B)))
cout << "Yes";
else
cout << "No";
}
// Driver Code
int main()
{
int X1 = 0, Y1 = 2;
int X2 = 0, Y2 = 14;
int X3 = 9, Y3 = 2;
checkRightAngled(X1, Y1, X2,
Y2, X3, Y3);
return 0;
}