Нужно написать программу в С++. Даны радиус окружности и сторона равностороннего треугольника. Определить, можно ли такой треугольник уместить внутри такой окружности.
cout << "Enter the radius of the circle: "; cin >> radius; cout << "Enter the side length of the equilateral triangle: "; cin >> side; // Calculate the height of the equilateral triangle triangleHeight = sqrt(pow(side, 2) - pow(side/2, 2)); // Check if the diameter of the circle is greater than the height of the triangle if (2 * radius >= triangleHeight) { cout << "The equilateral triangle can fit inside the circle." << endl; } else { cout << "The equilateral triangle cannot fit inside the circle." << endl; } return 0;
using namespace std;
int main() {
cout << "Enter the radius of the circle: ";double radius, side, triangleHeight;
cin >> radius;
cout << "Enter the side length of the equilateral triangle: ";
cin >> side;
// Calculate the height of the equilateral triangle
triangleHeight = sqrt(pow(side, 2) - pow(side/2, 2));
// Check if the diameter of the circle is greater than the height of the triangle
if (2 * radius >= triangleHeight) {
cout << "The equilateral triangle can fit inside the circle." << endl;
} else {
cout << "The equilateral triangle cannot fit inside the circle." << endl;
}
return 0;
}