Предмет: Информатика,
автор: olia15111
Вычислить площадь правильного N–угольника, в который вписана окруж-
ность диаметра D. Найти относительные ошибки замены площади такого N–угольника
площадью круга при значениях N, равных 12, 120, 720. Проверить правильность реше-
ния: при N=4 и любом D относительная ошибка должна быть равна 0,274.
Написать программу в С++
Ответы
Автор ответа:
0
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int
numOfSides,
diameter;
double
polygonArea;
cout << "Input number of sides: ";
cin >> numOfSides;
cout << "Input the diameter of the inscribed circle: ";
cin >> diameter;
polygonArea = numOfSides * (diameter * diameter / 4) * tan(PI / numOfSides);
cout << "Polygon area = " << polygonArea << ";nDelta = "
<< 1 - (PI * (diameter * diameter / 4)) / polygonArea << endl;
system("pause");
return 0;
} /* End of the 'main' function */
#include <cmath>
using namespace std;
int main()
{
int
numOfSides,
diameter;
double
polygonArea;
cout << "Input number of sides: ";
cin >> numOfSides;
cout << "Input the diameter of the inscribed circle: ";
cin >> diameter;
polygonArea = numOfSides * (diameter * diameter / 4) * tan(PI / numOfSides);
cout << "Polygon area = " << polygonArea << ";nDelta = "
<< 1 - (PI * (diameter * diameter / 4)) / polygonArea << endl;
system("pause");
return 0;
} /* End of the 'main' function */
Похожие вопросы
Предмет: Алгебра,
автор: aminadaudova57
Предмет: Геометрия,
автор: Bog666228
Предмет: Математика,
автор: Zhfcey
Предмет: Математика,
автор: миша999111
Предмет: Алгебра,
автор: klimenkol21