计算圆柱体表面积的程序

2025年1月8日 | 阅读需时 2 分钟

说明

在此程序中,我们有一个给定半径和高度的圆柱体。我们需要计算它的表面积。

圆柱体是一个三维几何图形/容器,具有直的平行侧面和两个圆形横截面。因此,圆柱体有三个表面。

两个圆形横截面的表面积 = 2( Π × r × r )

平行侧面的表面积 = 周长乘以高度 = 2 Π × r × h

圆柱体的总表面积 = 2( Π × r × r ) + 2 Π × r × h = 2 Π (r + h)

公式

Surface Area of Cylinder = 2 Π  (r + h)
Here, r is the radius and h is the height of the cylinder.
	Π ( pi ) = 22/7 = 3.14

算法

  1. 定义半径和高度的值。
  2. 代入给定公式。
  3. 打印圆柱体的表面积。

复杂度

O(1)


解决方案

Python

输出

Surface Area Of Cylinder :   44.0

C

输出

Surface Area of Cylinder is: 44.00000

JAVA

输出

Surface Area of Cylinder is:  44.000000

C#

输出

Surface Area of Cylinder is:  44

PHP

输出

Surface Area Of Cylinder is = 44
 
下一主题#