计算圆,球,圆锥,圆柱的表面积与体积

来源:互联网 发布:距离变换算法 编辑:程序博客网 时间:2024/04/30 14:40
上机内容:编写程序计算圆,球,圆锥,圆柱的表面积与体积上机目的:设计程序验证语法规则/*  * Copyright (c) 2012, 烟台大学计算机学院 * All rights reserved. * 作    者:  赵洋* 完成日期:2012 年 10 月 20 日 * 版 本 号:v1.0 * * 输入描述: 半径和高* 问题描述:利用输入的半径和高求圆,球,圆锥,圆柱的表面积与体积* 程序输出:圆,球,圆锥,圆柱的表面积与体积 * 问题分析:* 算法设计: */  #include<iostream>#include<Cmath>using namespace std;#define Pi 3.14int main(){double RoundArea;double RoungLength;double GlobeVolume;double GlobeArea;double ConeVolume;double ConeArea;double CylinderVolume;double CylinderArea;double r,h;cout<<"请输入半径:";cin>>r;cout<<"请输入高:";cin>>h;    RoundArea=Pi*r*r;    RoungLength=2*Pi*r;    GlobeVolume=4*Pi*r*r;    GlobeArea=(4*Pi*r*r*r)/3;    ConeVolume=(h*Pi*r*r)/3;    ConeArea=2*Pi*Pi*r*r*r;    CylinderVolume=Pi*r*r*h;    CylinderArea=2*Pi*r*h+2*Pi*r*r;cout<<"圆的面积是:"<<RoundArea<<endl;    cout<<"圆的周长是:"<<RoungLength<<endl;    cout<<"球的体积是:"<<GlobeVolume<<endl;    cout<<"球的表面积是:"<<GlobeArea<<endl;    cout<<"圆锥的体积是:"<<ConeVolume<<endl;    cout<<"圆锥的表面积是:"<<ConeArea<<endl;    cout<<"圆柱的体积是:"<<CylinderVolume<<endl;    cout<<"圆柱的表面积是:"<<CylinderArea<<endl;return 0;}

运行结果:

心得体会:一个大件完成了。。。

 

 

 

原创粉丝点击