計算等邊三角形內切圓面積和周長的程式\n什麼是 C 語言中的等邊三角形?


什麼是等邊三角形?

顧名思義,等邊三角形是指三條邊都相等,三個內角也都相等,每個內角都為 60°。它也被稱為正三角形,因為它是一個正多邊形。

等邊三角形的性質有:

  • 3 條邊長度相等
  • 內角度數相同,均為 60 度

內切圓

內切圓是指位於三角形內部的圓,這意味著圓心與三角形重合,如下圖所示。內切圓的圓心稱為內心,半徑稱為內半徑。

以下是等邊三角形內切圓的圖形

問題

給定等邊三角形的邊長,任務是找到其內切圓的面積和周長,其中面積是指圖形所佔的空間,體積是指圖形可以容納的空間。

為了計算等邊三角形內切圓的面積和周長,可以使用以下公式:

示例

Input-: side=6.0
Output-: Area of inscribed circle is :1.046667
   Perimeter of inscribed circle is :3.625760

演算法

Start
Step 1 -> define macro as
   #define pi 3.14
Step 2 -> Declare function to find area of inscribed circle
   float area(float a)
      return (a * a * (pi / 12))
step 3 -> Declare function to find Perimeter of inscribed circle
   float perimeter(float a)
      return (pi * (a / sqrt(3)))
step 4 -> In main()
   Declare variable as float a = 6.0
   Call area(a)
   Call perimeter(a)
Stop

示例

#include <math.h>
#include <stdio.h>
#define pi 3.14
// function to find area of inscribed circle
float area(float a){
   return (a * a * (pi / 12));
}
// function to find Perimeter of inscribed circle
float perimeter(float a){
   return (pi * (a / sqrt(3)));
}
int main(){
   float a = 6.0;
   printf("Area of inscribed circle is :%f
",area(a));    printf("Perimeter of inscribed circle is :%f",perimeter(a));    return 0; }

輸出

Area of inscribed circle is :1.046667
Perimeter of inscribed circle is :3.625760

更新於: 2019 年 9 月 20 日

159 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始學習
廣告

© . All rights reserved.