# Untitled

unknown
c_cpp
2 years ago
1.7 kB
7
Indexable
Never
```#include <bits/stdc++.h>
using namespace std;

int main()
{
float a,b,c;
cin >> a >> b >> c;

//Neu khong phai tam giac
if (a+b<=c || b+c<=a || a+c<=b)
{
cout <<"Khong phai la 3 canh tam giac. \n";
}

//Kiem tra co phai la tam giac
if (a+b>c && b+c>a && a+c>b)
{
//Kiem tra tam giac deu
if (a==b && a==c)
{
float cv = a+b+c;
float p = cv/2;
float dt = sqrt((p*(p-a)*(p-b)*(p-c)));
cout <<"Tam giac deu \n";
cout <<"Chu vi = " << cv << endl;
cout <<"Dien tich = " << dt << endl;
}

//Kiem tra tam giac can
if (a==b || b==c || a==c)
{
float cv = a+b+c;
float p = cv/2;
float dt = sqrt((p*(p-a)*(p-b)*(p-c)));
cout <<"Tam giac can \n";
cout <<"Chu vi = " << cv << endl;
cout <<"Dien tich = " << dt << endl;
}

//Kiem tra tam giac tu
if (a*a > b*b + c*c || b*b > a*a+ c*c || c*c > a*a + b*b)
{
float cv = a+b+c;
float p = cv/2;
float dt = sqrt((p*(p-a)*(p-b)*(p-c)));
cout <<"Tam giac tu \n";
cout <<"Chu vi = " << cv << endl;
cout <<"Dien tich = " << dt << endl;
}

//Kiem tra tam giac vuong
if (a*a == b*b + c*c || b*b == a*a+ c*c || c*c == a*a + b*b)
{
float cv = a+b+c;
float p = cv/2;
float dt = sqrt((p*(p-a)*(p-b)*(p-c)));
cout <<"Tam giac vuong \n";
cout <<"Chu vi = " << cv << endl;
cout <<"Dien tich = " << dt << endl;

//Khong thoa man tat ca dieu kien tren thi la tam giac nhon
float cv = a+b+c;
float p = cv/2;
float dt = sqrt((p*(p-a)*(p-b)*(p-c)));
cout <<"Tam giac nhon \n";
cout <<"Chu vi = " << cv << endl;
cout <<"Dien tich = " << dt << endl;
}
}

return 0;
}```