Đây là nửa chu vi và a, b, c là ba cạnh của tam giác. Hãy hiểu ví dụ sau
Xem ví dụ này
đầu ra
Enter first side: 5 Enter second side: 6 Enter third side: 7 The area of the triangle is 14.70
Giải trình -
Ta lấy đầu vào là 3 cạnh của một tam giác và lưu chúng vào 3 biến a, b, c. Sau đó, chúng tôi đã tính nửa chu vi của tam giác và đưa giá trị này vào công thức diện tích của tam giác
Cho ba số nguyên X, Y, Z đại diện cho ba cạnh của một tam giác, nhiệm vụ là kiểm tra xem tam giác tạo thành bởi các cạnh đã cho là tam giác đều, cân hay cân
Tam giác đều. Một tam giác được gọi là tam giác đều nếu tất cả các cạnh bằng nhau. Nếu X, Y, Z là ba cạnh của tam giác. Khi đó tam giác đều chỉ khi X = Y = Z
Tam giác cân. Một tam giác được gọi là tam giác cân nếu hai cạnh bất kì bằng nhau. Nếu X, Y, Z là ba cạnh của tam giác. Khi đó, tam giác cân nếu X = Y hoặc X = Z hoặc Y = Z
Tam giác cân. Một tam giác được gọi là Tam giác cân nếu không có cạnh nào bằng nhau
ví dụ
Đầu vào. X = 6, Y = 8, Z = 10
Đầu ra. Tam giác cân
Giải thích.
Vì tất cả các cạnh của tam giác đã cho đều không bằng nhau nên tam giác đó cân.Đầu vào. X = 10, Y = 10, Z = 10
Đầu ra. Tam giác đều
Giải thích.
Vì tất cả các cạnh của tam giác đã cho đều bằng nhau.
Khuyến khích. Vui lòng thử cách tiếp cận của bạn trên {IDE} trước, trước khi chuyển sang giải pháp
Cách tiếp cận. Thực hiện theo các bước dưới đây để giải quyết vấn đề
- Kiểm tra xem X = Y và Y = Z. Nếu thấy đúng, in ra “Tam giác đều”
- Nếu nó không phải là tam giác đều, hãy kiểm tra xem X = Y hoặc X = Z hoặc Y = Z. Nếu thấy đúng, hãy in ra “Tam giác cân”
- Nếu không có bước nào ở trên thỏa mãn, thì hãy in “Scalene Triangle”
Dưới đây là việc thực hiện các phương pháp trên
C++
// C++ program for the above approach
#include
using
namespace
std;
// Function to check if the triangle
// is equilateral or isosceles or scalene
void
checkTriangle[
// C++ program for the above approach
0 // C++ program for the above approach
1// C++ program for the above approach
0 // C++ program for the above approach
3// C++ program for the above approach
0 // C++ program for the above approach
5
// C++ program for the above approach
6
// C++ program for the above approach
7
// C++ program for the above approach
7____19
// C++ program for the above approach
7____21 #include
2
#include
3#include
4#include
5#include
6
// C++ program for the above approach
7____28
// C++ program for the above approach
7using
0 #include
1 using
2
#include
3#include
4using
5#include
6
// C++ program for the above approach
7____38
// C++ program for the above approach
7____30
#include
3#include
4namespace
3#include
6
namespace
5
namespace
6
// C++ program for the above approach
0 namespace
8
// C++ program for the above approach
6
// C++ program for the above approach
7
// C++ program for the above approach
7____52
// C++ program for the above approach
7____10 std;
5
// C++ program for the above approach
7
// C++ program for the above approach
7____58
// C++ program for the above approach
7____60
namespace
5
// Function to check if the triangle
2
Java
// Function to check if the triangle
3
// Function to check if the triangle
4 // Function to check if the triangle
5
// C++ program for the above approach
7
// Function to check if the triangle
// is equilateral or isosceles or scalene
// Function to check if the triangle
9 void
checkTriangle[
// C++ program for the above approach
0 // C++ program for the above approach
1// C++ program for the above approach
0 // C++ program for the above approach
3// C++ program for the above approach
0 // C++ program for the above approach
5
// C++ program for the above approach
6
// C++ program for the above approach
7____19
// C++ program for the above approach
7____21 void
3
#include
3____85#include
5void
7
// C++ program for the above approach
7____28
// C++ program for the above approach
7using
0 #include
1 checkTriangle[
3
#include
3____85using
5void
7
// C++ program for the above approach
7____38
// C++ program for the above approach
7____30
#include
3void
5namespace
3void
7
namespace
5
namespace
6
// C++ program for the above approach
08 // Function to check if the triangle
9 void
// C++ program for the above approach
11
// C++ program for the above approach
6
// C++ program for the above approach
7
// C++ program for the above approach
7____52
// C++ program for the above approach
7__// C++ program for the above approach
0 // C++ program for the above approach
18// C++ program for the above approach
19// C++ program for the above approach
20// C++ program for the above approach
21// C++ program for the above approach
22// C++ program for the above approach
23#include
6
// C++ program for the above approach
7
// C++ program for the above approach
7____58
// C++ program for the above approach
7____60
namespace
5
namespace
5
// Function to check if the triangle
2
Python3
// C++ program for the above approach
33
// C++ program for the above approach
34
// C++ program for the above approach
35
// C++ program for the above approach
36 // C++ program for the above approach
37
// C++ program for the above approach
7____139
// C++ program for the above approach
7_______21 // C++ program for the above approach
42____143// C++ program for the above approach
43 // C++ program for the above approach
45// C++ program for the above approach
43// C++ program for the above approach
43 // C++ program for the above approach
48
#include
3____150____151____25// C++ program for the above approach
53
// C++ program for the above approach
7____155
// C++ program for the above approach
7_______157 // C++ program for the above approach
42// C++ program for the above approach
43// C++ program for the above approach
43 // C++ program for the above approach
45// C++ program for the above approach
62 // C++ program for the above approach
45// C++ program for the above approach
43// C++ program for the above approach
43 // C++ program for the above approach
66// C++ program for the above approach
62 // C++ program for the above approach
66// C++ program for the above approach
43// C++ program for the above approach
43 // C++ program for the above approach
71