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

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

相关推荐
MSTcheng.几秒前
【C++STL】map / multimap 保姆级教程:从底层原理到实战应用!
开发语言·c++·stl·map·红黑树
ULTRA??9 分钟前
基于range的函数式编程C++,python比较
c++·python·kotlin·c++20
闻缺陷则喜何志丹26 分钟前
【计算几何 二分查找】P5485 [JLOI2010] 铁人双项比赛|普及+
c++·数学·二分查找·计算几何·洛谷
..空空的人30 分钟前
C++基于protobuf实现仿RabbitMQ消息队列---服务器模块认识1
服务器·开发语言·c++·分布式·rabbitmq·protobuf
晨非辰39 分钟前
基于Win32 API控制台的贪吃蛇游戏:从设计到C语言实现详解
c语言·c++·人工智能·后端·python·深度学习·游戏
小此方43 分钟前
Re: ゼロから学ぶ C++ 入門(六)类和对象·第三篇:运算符重载
开发语言·c++·后端
2301_7890156243 分钟前
每日精讲:环形链表、两个数组中的交集、随机链表的复制
c语言·数据结构·c++·算法·leetcode·链表·排序算法
2301_789015622 小时前
C++:二叉搜索树
c语言·开发语言·数据结构·c++·算法·排序算法
leiming69 小时前
C++ vector容器
开发语言·c++·算法
apocelipes12 小时前
从源码角度解析C++20新特性如何简化线程超时取消
c++·性能优化·golang·并发·c++20·linux编程