C程序中内接于等边三角形的外接圆的内接正方形的面积?
这里我们将看到一个正方形的面积,它内接于一个圆,而这个圆内接于一个等边三角形。正方形的边长为‘a’。圆的半径为‘r’,等边三角形的边长为‘A’。图示如下。

我们知道内接于等边三角形的圆的半径是三角形的内切圆半径。所以值为 -

所以正方形的对角线为 -

所以正方形的面积为 -

示例
#include <iostream>
#include <cmath>
using namespace std;
float area(float A) { //A is the side of the triangle
if (A < 0) //if the value is negative it is invalid
return -1;
float d = A / sqrt(3);
float area = 0.5*d*d;
return area;
}
int main() {
float side = 10;
cout << "Area is: " << area(side);
}输出
Area is: 16.6667
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP