Xác định chương trình tam giác trong python

Đâ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 đề

  1. Kiểm tra xem X = Y và Y = Z. Nếu thấy đúng, in ra “Tam giác đều”
  2. 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”
  3. 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 approach0 // C++ program for the above approach1// C++ program for the above approach0 // C++ program for the above approach3// C++ program for the above approach0 // C++ program for the above approach5

// C++ program for the above approach6

// C++ program for the above approach7

// C++ program for the above approach7____19

// C++ program for the above approach7____21 #include 2

#include 3#include 4#include 5#include 6

 

// C++ program for the above approach7____28

// C++ program for the above approach7using0 #include 1 using2

#include 3#include 4using5#include 6

 

// C++ program for the above approach7____38

// C++ program for the above approach7____30

#include 3#include 4namespace3#include 6

namespace5

 

namespace6

// C++ program for the above approach0 namespace8

// C++ program for the above approach6

// C++ program for the above approach7

// C++ program for the above approach7____52

// C++ program for the above approach7____10 std;5

// C++ program for the above approach7

// C++ program for the above approach7____58

// C++ program for the above approach7____60

namespace5

 

// Function to check if the triangle2

Java




// Function to check if the triangle3

// Function to check if the triangle4 // Function to check if the triangle5

// C++ program for the above approach7

// Function to check if the triangle

// is equilateral or isosceles or scalene

// Function to check if the triangle9 void checkTriangle[// C++ program for the above approach0 // C++ program for the above approach1// C++ program for the above approach0 // C++ program for the above approach3// C++ program for the above approach0 // C++ program for the above approach5

// C++ program for the above approach6

 

// C++ program for the above approach7____19

// C++ program for the above approach7____21 void3

#include 3____85#include 5void7

 

// C++ program for the above approach7____28

// C++ program for the above approach7using0 #include 1 checkTriangle[3

#include 3____85using5void7

 

// C++ program for the above approach7____38

// C++ program for the above approach7____30

#include 3void5namespace3void7

namespace5

 

namespace6

// C++ program for the above approach08 // Function to check if the triangle9 void // C++ program for the above approach11

// C++ program for the above approach6

// C++ program for the above approach7

// C++ program for the above approach7____52

// C++ program for the above approach7__// C++ program for the above approach0 // C++ program for the above approach18// C++ program for the above approach19// C++ program for the above approach20// C++ program for the above approach21// C++ program for the above approach22// C++ program for the above approach23#include 6

// C++ program for the above approach7

// C++ program for the above approach7____58

// C++ program for the above approach7____60

namespace5

namespace5

 

// Function to check if the triangle2

Python3




// C++ program for the above approach33

 

// C++ program for the above approach34

// C++ program for the above approach35

// C++ program for the above approach36 // C++ program for the above approach37

 

// C++ program for the above approach7____139

// C++ program for the above approach7_______21 // C++ program for the above approach42____143// C++ program for the above approach43 // C++ program for the above approach45// C++ program for the above approach43// C++ program for the above approach43 // C++ program for the above approach48

#include 3____150____151____25// C++ program for the above approach53

 

// C++ program for the above approach7____155

// C++ program for the above approach7_______157 // C++ program for the above approach42// C++ program for the above approach43// C++ program for the above approach43 // C++ program for the above approach45// C++ program for the above approach62 // C++ program for the above approach45// C++ program for the above approach43// C++ program for the above approach43 // C++ program for the above approach66// C++ program for the above approach62 // C++ program for the above approach66// C++ program for the above approach43// C++ program for the above approach43 // C++ program for the above approach71

Chủ Đề