Hi
I need help with a function to determine if a triangle is a right angled triangle when three points are entered. Hers's what I have so far, it's the function at the bottomthat I struggle with:
#include <iostream>
using namespace std;
struct pointType
{
int x;
int y;
};
void read(pointType& p);
bool isRightTriangle(const pointType p1, const pointType p2, const pointType p3);
int main()
{
pointType point1, point2, point3;
cout << "Enter two integers for point 1: " << flush;
read(point1);
cout << "Enter two integers for point 2: " << flush;
read(point2);
cout << "Enter two integers for point 3: " << flush;
read(point3);
if (isRightTriangle(point1, point2, point3))
cout << "The three points form a right-angled triangle." << endl;
else
cout << "The three points don't form a right-angled triangle." << endl;
return 0;
}
void read(pointType& p)
{
cin >> p.x >> p.y;
}
bool isRightTriangle(const pointType p1, const pointType p2, const pointType p3)
{
// This is the function I'm struggling with
}
Thanks