# Untitled

unknown
plain_text
3 years ago
1.8 kB
1
Indexable
Never
```#include<iostream>
#include<cmath>
using namespace std;

//tinh chieu dai cac canh
float tinhcanh(float ax, float ay, float bx,float by) {
float ab;
ab = sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay));
return ab;

}

// ham kiem tra tam giac
void typeofTriangle(float arr[6]) {
float ab, bc, ca;

ab = tinhcanh(arr[0], arr[1], arr[2], arr[3]);
bc = tinhcanh(arr[2], arr[3], arr[4], arr[5]);
ca = tinhcanh(arr[4], arr[5], arr[0], arr[1]);
cout << ab <<" "<< bc << " " << ca << endl;
// kiem tra co phai la 1 tam gia
if ((ab + bc < ca) || (bc + ca < ab) || (ca + ab < bc)) {
cout << "Not a Triangle."<<endl;
return;
}
//kiem tra tam giac cdeu
if (ab == bc&&bc == ca) {
cout << "Equilateral Triangle." << endl;
return;
}
// kiem tra tam giac can va cuong can
if (ab == bc || bc == ca || ca == ab) {
if ((ab * ab + bc * bc == ca * ca) || (ca * ca + bc * bc == ab * ab) || (ab * ab + ca * ca == bc * bc)) {
cout << "Right-Isosceles Triangle." << endl;
return;
}
else {
cout << "Isosceles Triangle." << endl;
}
}

// kiem tra tam giac vuong thuong
if ((ab * ab + bc * bc == ca * ca) || (ca * ca + bc * bc == ab * ab) || (ab * ab + ca * ca == bc * bc)) {
cout << "Right Triangle." << endl;
return;
}
//khong gap cac truong hop tren la tam giac thuong
cout << " Nonaml Triangle."<<endl;
return;

}

int main() {

float arr[6];
//nhap toa do 3 diem cua tam giac
cout << "Nhap toa do 3 diem cua tam giac" << endl;
for (int i = 0; i < 6; i++) {
do{
cin >> arr[i];
if (arr[i] < 0 || arr[i]>2020) {
cout << "Moi nhap lai toa do(0->2020).";
}
} while (arr[i] < 0 || arr[i]>2020);

}

// kiem tra tam giac
typeofTriangle(arr);
return 0;
}```