C++ 圆台体积和表面积计算程序(Program for Volume and Surface area of Frustum of Cone)

给定圆锥台的斜高、高度和半径,我们必须计算圆锥台的体积和表面积。

圆台

在几何学中,截头体是指立体(通常是圆锥或金字塔)被一个或两个平行平面截开的部分。如果我们用一个平行于其底面的平面截一个直圆锥,则该平面与底面之间的部分称为圆锥截头体。下图是一个直圆锥。

如果您喜欢此文章,请收藏、点赞、评论,谢谢,祝您快乐每一天。

直圆锥被平行于其底面的平面切割后,形成如下的截头体:

其底部为圆形,半径为 R,上部为圆形,半径为 r,高度为 h,斜高为 l

圆台体积

体积 (V) = 1/3 * pi * h(r^2 + R^2 + r*R)

其中

r = 较小圆的半径

R = 较大圆的半径(或圆锥底面的半径)

h = 截头锥体的高度

圆台曲面面积

曲面面积 (CSA) = pi * l(R + r)

其中

r = 较小圆的半径

R = 较大圆的半径

l = 截头锥体的斜高

圆台总表面积

总表面积 (TSA) = pi * l(R + r) + pi(R^2 + r^2 )

其中

r = 较小圆的半径

R = 较大圆的半径

l = 截头锥体的斜高

例子

输入:小圆的半径 = 3

大圆的半径 = 8

截头体的高度 = 12

截头体的斜高 = 13

输出:

圆台体积:1218.937

圆台曲面面积:449.24738 圆台

总表面积:678.58344

输入:小圆的半径 = 7

大圆的半径 = 10

截头体的高度 = 4

截头体的斜高 = 5

输出:

圆台体积:917.34436

圆台曲面面积:267.03516

圆台总表面积:735.1321

示例代码

// CPP program to calculate Volume and

// Surface area of frustum of cone

#include <iostream>

using namespace std;

float pi = 3.14159;

// Function to calculate Volume of frustum of cone

float volume(float r, float R, float h)

{

return (float(1) / float(3)) * pi * h *

(r * r + R * R + r * R);

}

// Function to calculate Curved Surface area of

// frustum of cone

float curved_surface_area(float r, float R, float l)

{

return pi * l * (R + r);

}

// Function to calculate Total Surface area of

// frustum of cone

float total_surface_area(float r, float R, float l,

float h)

{

return pi * l * (R + r) + pi * (r * r + R * R);

}

// Driver function

int main()

{

float small_radius = 3;

float big_radius = 8;

float slant_height = 13;

float height = 12;

// Printing value of volume and surface area

cout << "Volume Of Frustum of Cone : "

<< volume(small_radius, big_radius, height)

<< endl;

cout << "Curved Surface Area Of Frustum of Cone : "

<< curved_surface_area(small_radius, big_radius,

slant_height) << endl;

cout << "Total Surface Area Of Frustum of Cone : "

<< total_surface_area(small_radius, big_radius,

slant_height, height);

return 0;

}

输出:

圆锥台体积:1218.937

圆锥台曲面面积:449.24738

圆锥台总表面积:678.58344

如果您喜欢此文章,请收藏、点赞、评论,谢谢,祝您快乐每一天。

相关推荐
博客180010 小时前
酷宝的使用方法,超好用的免费界面库,C++、MFC可用
c++·mfc·界面库·库来帮·酷宝
郝学胜_神的一滴11 小时前
CMake 026:属性体系精讲、四大作用域全解 & 实战代码落地
c++·cmake
众少成多积小致巨1 天前
JNI (Java Native Interface) 技术手册中文参考指南
android·java·c++
clint4565 天前
C++进阶(1)——前景提要
c++
夜悊5 天前
C++代码示例:进制数简单生成工具
c++
郝学胜_神的一滴5 天前
CMake 021: IF 条件判据详诠
c++·cmake
_wyt0016 天前
洛谷 B3930 [GESP202312 五级] 烹饪问题 题解
c++·gesp
玖玥拾6 天前
C/C++ 数据结构(七)栈、容器适配器
c语言·数据结构·c++··容器适配器
один but you6 天前
constexpr函数
c++
凡人叶枫6 天前
Effective C++ 条款41:了解隐式接口和编译期多态
java·开发语言·c++·effective c++