
С клавиатуры вводится 2 угла и 3 стороны треугольника,написать программу,которая определяет вид
треугольника(Прямоугольный,Равнобедренный,Равносторонний,Тупо угольный, Остроугольный)На c++

Ответы на вопрос

#include <iostream>
using namespace std;
int main()
{
setlocale(LC_ALL, "rus");
float a, b, c, x1, x2;
cout << "Введите основную сторону: \n";
cin >> a;
cout << "Введите две других: \n";
cin >> b;cin >> c;
cout << "Введите углы: \n";
cin >> x1; cin >> x2;
if (a*a == b*b + c*c) cout << "Прямоугольный\n";
if (a*a < b*b + c*c) cout << "Остроугольный\n";
if (a*a > b*b + c*c) cout << "Тупоугольный\n";
if (x1 == x2) cout << "Равнобедренный\n";
if (a == b && b == c) cout << "Равносторонний \n";
system("pause");
return 0;
}



Writing a Program to Determine the Type of Triangle in C++
To write a program in C++ that determines the type of triangle based on the input of 2 angles and 3 sides, you can use the following approach:
1. Input the Angles and Sides: - Prompt the user to input the values of the 2 angles and 3 sides of the triangle.
2. Calculate the Type of Triangle: - Use the input values to determine the type of triangle based on its angles and sides. - Check for conditions such as the sum of angles, the equality of sides, and the relationship between angles and sides to determine the type of triangle.
3. Output the Result: - Display the type of triangle based on the input values.
Here's a sample program in C++ that accomplishes this:
```cpp
#include
int main() { int angle1, angle2, side1, side2, side3;
// Input the values of the angles and sides cout << "Enter the value of angle 1: "; cin >> angle1; cout << "Enter the value of angle 2: "; cin >> angle2; cout << "Enter the value of side 1: "; cin >> side1; cout << "Enter the value of side 2: "; cin >> side2; cout << "Enter the value of side 3: "; cin >> side3;
// Calculate the type of triangle if (angle1 + angle2 == 90) { cout << "The triangle is a right-angled triangle." << endl; } else if (angle1 == angle2) { if (side1 == side2 && side2 == side3) { cout << "The triangle is an equilateral triangle." << endl; } else { cout << "The triangle is an isosceles triangle." << endl; } } else { cout << "The triangle is a scalene triangle." << endl; }
return 0; } ```
This program prompts the user to input the values of the angles and sides of the triangle and then determines the type of triangle based on the input values. It checks for conditions such as the sum of angles, the equality of sides, and the relationship between angles and sides to determine the type of triangle.
Remember to compile and run the program to see the output based on different input values.


Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili