Little Monkey Programming C++ | Triangle Classification

Learn C++ from a young age! Record the questions in the learning process of Xueersi Monkey programming and record every moment. Any infringement will be deleted immediately, thank you for your support!

Attached is a summary post: Little Monkey Programming C++ | Summary-CSDN Blog


[Title description]

Given three angles  a , b , c , the length of the two sides of the angle is not considered, only the angle is considered. Please determine what kind of triangle this triangle can form:

If a triangle cannot be formed, an Error is output;

If an equilateral triangle can be formed, output Equilateral;

If an isosceles right triangle can be formed, output Isosceles right;

If an isosceles triangle can be formed, output Isosceles;

If a right triangle can be formed, output Right;

If a triangle can be formed, output Scalene.

Note : Only one result is output for each query, and the priority is from high to low in the order of the question description.

【enter】

A line contains   three positive integers a , b , c .

【Output】

Output the corresponding string according to the question requirements.

【Input sample】

60 60 60

【Output sample】

Equilateral

[Detailed code explanation]

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b+c!=180) cout << "Error";
    else if (a==b && b==c) cout << "Equilateral";
    else if ((a==90 && b==c) || (b==90 && a==c) || (c==90 && a==b)) cout << "Isosceles right";
    else if (a==b || b==c || a==c) cout << "Isosceles";
    else if (a==90 || b==90 || c==90) cout << "Right";
    else cout << "Scalene";
    return 0;
}

【operation result】

60 60 60
Equilateral

Guess you like

Origin blog.csdn.net/guolianggsta/article/details/133930289