📜  计算Enneagon面积的程序

📅  最后修改于: 2021-10-23 08:13:10             🧑  作者: Mango

Enneagon 是一个有 9 个边和 9 个内角的多边形。 Enneagon也被称为Nonagon。规则的九边形各有一个 140 度的内角。九边形的内角和是1260度。
外接圆的中心也取为规则九边形的中心。
垂直于九边形一侧绘制的线段称为 Apothem,用“a”表示。

Area ≈ 6.1818 * s * s 
 where s is side length.

例子:

Input : 6
Output :Area of Regular Nonagon = 222.5448

Input : 8 
Output :Area of Regular Nonagon = 395.6352
C++
// CPP program to find area of a Enneagon
#include 
#include 
#include 
using namespace std;
 
// Function to calculate area of nonagon
double Nonagon_Area(double s) {
  return (6.1818 * s * s);
}
 
// driver function
int main() {
  double s = 6; // Length of a side
  cout << "Area of Regular Nonagon = " << std::setprecision(7)
       << Nonagon_Area(s);
  return 0;
}


Java
// Java program to find area of a Enneagon
class Nonagon {
 
  // Function for calculating the area of the nonagon
  public static double Nonagon_Area(double s) {
    return ((6.1818 * (s * s)));
  }
 
  // driver code
  public static void main(String[] args) {
    double s = 6; // Length of a side
    System.out.print("Area of Regular Nonagon = " + Nonagon_Area(s));
  }
}


Python
# python program to find area of a Enneagon
length = 6
Nonagon_area = 6.1818 * (length ** 2)
print("Area of regular Nonagon is = ", Nonagon_area)


C#
// C# program to find area of a Hexagon
using System;
 
class Nonagon {
 
    // Function for calculating
    // the area of the nonagon
    public static double Nonagon_Area(double s)
    {
        return ((6.1818 * (s * s)));
    }
 
    // driver code
    public static void Main()
    {  
        // Length of a side
        double s = 6;
        Console.WriteLine("Area of Regular Nonagon = " +
                                       Nonagon_Area(s));
    }
}
 
// This article is contributed by vt_m


PHP


Javascript


输出:
Area of Regular Nonagon = 222.5448