可以在等邊三角形內切入的面積最大的正方形?


在這裡,我們將瞭解能在等邊三角形內切入的面積最大的正方形。三角形的一邊是“a”,正方形的一邊是 x。

三角形的一邊“a”是 −

所以 x 是 −

示例

#include <iostream>
#include <cmath>
using namespace std;
float areaSquare(float a) { //a is side of triangle
   if (a < 0 ) //if a is negative, then this is invalid
      return -1;
   float area = a / (1 + 2/sqrt(3));
   return area;
}
int main() {
   float a = 7;
   cout << "Area of Rectangle: " << areaSquare(a);
}

輸出

Area of Rectangle: 3.24871

01-08-2019

194 閱讀

開啟您的職業生涯

完成課程,獲得認證

開始學習
廣告
© . All rights reserved.