以 C++ 编写可在任何正多边形中找出外接圆程序
本题给出了两个数字,表示多边形的边数 N 和每条边的长度 A。我们的任务是编写一个程序,在 C++ 中找出任何正多边形的外接圆。
题目描述 − 在此,我们需要找出边数和长度已知正多边形外接圆的半径和面积。
我们举个例子来理解这个问题,
输入
n = 4 a = 2
程序演示了我们解决方案的工作原理,
示例
#include <bits/stdc++.h>
using namespace std;
void CalcRadAreaCircumcircle(float n, float a) {
float r = a / sqrt( 2 * ( 1 - cos(360 / n)));
cout<<"The radius of Circumcircle is "<<r<<endl;
cout<<"The area of circumcircle is "<<((3.14)*r*r);
}
int main() {
float n = 5, a = 6;
CalcRadAreaCircumcircle(n, a);
return 0;
}输出
The radius of Circumcircle is 3.02487 The area of circumcircle is 28.7305
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP